@@ -121,6 +121,9 @@ |
||
121 | 121 | return $out; |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @param string $text |
|
126 | + */ |
|
124 | 127 | function output_code_wrap($text) |
125 | 128 | { |
126 | 129 | if(KSESTEST_ENV == 'CLI') |
@@ -1,507 +1,507 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | - // This is a q&d program that shows some of the results of |
|
4 | - // running KSES. If you have further questions, check the |
|
5 | - // current valid email address at http://chaos.org/contact/ |
|
6 | - |
|
7 | - // Make sure we're in a usable PHP environment |
|
8 | - if(substr(phpversion(), 0, 1) < 4) |
|
9 | - { |
|
10 | - define('KSESTEST_VER', 0); |
|
11 | - } |
|
12 | - elseif(substr(phpversion(), 0, 1) >= 5) |
|
13 | - { |
|
14 | - define('KSESTEST_VER', 5); |
|
15 | - } |
|
16 | - else |
|
17 | - { |
|
18 | - define('KSESTEST_VER', 4); |
|
19 | - } |
|
20 | - |
|
21 | - // See if we're in command line or web |
|
22 | - if($_SERVER["DOCUMENT_ROOT"] == "") |
|
23 | - { |
|
24 | - define('KSESTEST_ENV', 'CLI'); |
|
25 | - } |
|
26 | - else |
|
27 | - { |
|
28 | - define('KSESTEST_ENV', 'WEB'); |
|
29 | - } |
|
30 | - |
|
31 | - if(KSESTEST_VER == 0) |
|
32 | - { |
|
33 | - $message = array( |
|
34 | - "Error: Not using a current version of PHP!", |
|
35 | - "You are using PHP version " . phpversion() . ".", |
|
36 | - "KSES Class version requires PHP4 or better.", |
|
37 | - "KSES test program ending." |
|
38 | - ); |
|
39 | - |
|
40 | - displayPage( |
|
41 | - array("title" => "Error running KSES test", "message" => $message) |
|
42 | - ); |
|
43 | - |
|
44 | - exit(); |
|
45 | - } |
|
46 | - |
|
47 | - $include_file = "php" . KSESTEST_VER . ".class.kses.php"; |
|
48 | - if(file_exists($include_file) && is_readable($include_file)) |
|
49 | - { |
|
50 | - include_once($include_file); |
|
51 | - } |
|
52 | - else |
|
53 | - { |
|
54 | - $message = array( |
|
55 | - "Error: Unable to find '" . $include_file . "'.", |
|
56 | - "Please check your include path and make sure the file is available.", |
|
57 | - "Path: " . ini_get('include_path') |
|
58 | - ); |
|
59 | - |
|
60 | - displayPage( |
|
61 | - array('title' => 'Unable to include ' . $include_file, 'message' => $message) |
|
62 | - ); |
|
63 | - |
|
64 | - exit(); |
|
65 | - } |
|
66 | - |
|
67 | - $kses_type = "kses" . KSESTEST_VER; |
|
68 | - $myKses = new $kses_type; |
|
69 | - |
|
70 | - $test_text = array(); |
|
71 | - $test_text = test1_protocols($myKses); |
|
72 | - $test_text = array_merge($test_text, test1_html($myKses)); |
|
73 | - $test_text = array_merge($test_text, test1_kses($myKses)); |
|
74 | - |
|
75 | - displayPage( |
|
76 | - array('title' => 'New Test', 'message' => $test_text) |
|
77 | - ); |
|
78 | - |
|
79 | - function test1_kses(&$myKses) |
|
80 | - { |
|
81 | - $out = array(output_hr(), "Testing current configuration"); |
|
82 | - |
|
83 | - $test_tags = array( |
|
84 | - '<a href="http://www.chaos.org/">www.chaos.org</a>', |
|
85 | - '<a name="X">Short \'a name\' tag</a>', |
|
86 | - '<td colspan="3" rowspan="5">Foo</td>', |
|
87 | - '<td rowspan="2" class="mugwump" style="background-color: rgb(255, 204 204);">Bar</td>', |
|
88 | - '<td nowrap>Very Long String running to 1000 characters...</td>', |
|
89 | - '<td bgcolor="#00ff00" nowrap>Very Long String with a blue background</td>', |
|
90 | - '<a href="proto1://www.foo.com">New protocol test</a>', |
|
91 | - '<img src="proto2://www.foo.com" />', |
|
92 | - '<a href="javascript:javascript:javascript:javascript:javascript:alert(\'Boo!\');">bleep</a>', |
|
93 | - '<a href="proto4://abc.xyz.foo.com">Another new protocol</a>', |
|
94 | - '<a href="proto9://foo.foo.foo.foo.foo.org/">Test of "proto9"</a>', |
|
95 | - '<td width="75">Bar!</td>', |
|
96 | - '<td width="200">Long Cell</td>' |
|
97 | - ); |
|
98 | - |
|
99 | - $out_li = array(); |
|
100 | - // Keep only allowed HTML from the presumed 'form'. |
|
101 | - foreach($test_tags as $tag) |
|
102 | - { |
|
103 | - $temp = $myKses->Parse($tag); |
|
104 | - $check = ($temp == $tag) ? true : false; |
|
105 | - $text = ($temp == $tag) ? 'pass' : 'fail'; |
|
106 | - |
|
107 | - $li_text = output_testresult($check, $text) . output_newline(); |
|
108 | - $li_text .= "Input: " . output_translate($tag) . output_newline(); |
|
109 | - $li_text .= "Output: " . output_translate($temp); |
|
110 | - if(KSESTEST_ENV == 'CLI') |
|
111 | - { |
|
112 | - $li_text .= output_newline(); |
|
113 | - } |
|
114 | - |
|
115 | - array_push($out_li, output_code_wrap($li_text)); |
|
116 | - } |
|
117 | - |
|
118 | - $out = array_merge($out, array(output_ul($out_li))); |
|
119 | - array_push($out, output_hr()); |
|
120 | - array_push($out, "Testing is now finished."); |
|
121 | - return $out; |
|
122 | - } |
|
123 | - |
|
124 | - function output_code_wrap($text) |
|
125 | - { |
|
126 | - if(KSESTEST_ENV == 'CLI') |
|
127 | - { |
|
128 | - return $text; |
|
129 | - } |
|
130 | - else |
|
131 | - { |
|
132 | - return "<code>\n$text<code>\n"; |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - function output_translate($text) |
|
137 | - { |
|
138 | - if(KSESTEST_ENV == 'CLI') |
|
139 | - { |
|
140 | - return $text; |
|
141 | - } |
|
142 | - else |
|
143 | - { |
|
144 | - return htmlentities($text); |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - function output_testresult($pass = false, $text = "") |
|
149 | - { |
|
150 | - if(KSESTEST_ENV == 'CLI') |
|
151 | - { |
|
152 | - return '[' . $text . ']'; |
|
153 | - } |
|
154 | - else |
|
155 | - { |
|
156 | - if($pass == true) |
|
157 | - { |
|
158 | - return '<span style="color: green;">[' . $text . ']</span>'; |
|
159 | - } |
|
160 | - else |
|
161 | - { |
|
162 | - return '<span style="color: red;">[' . $text . ']</span>'; |
|
163 | - } |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - function output_spaces() |
|
168 | - { |
|
169 | - if(KSESTEST_ENV == 'WEB') |
|
170 | - { |
|
171 | - $out = " "; |
|
172 | - } |
|
173 | - else |
|
174 | - { |
|
175 | - $out = " "; |
|
176 | - } |
|
177 | - |
|
178 | - return $out; |
|
179 | - } |
|
180 | - |
|
181 | - function output_newline() |
|
182 | - { |
|
183 | - if(KSESTEST_ENV == 'WEB') |
|
184 | - { |
|
185 | - $out = "<br />\n"; |
|
186 | - } |
|
187 | - else |
|
188 | - { |
|
189 | - $out = "\n"; |
|
190 | - } |
|
191 | - |
|
192 | - return $out; |
|
193 | - } |
|
194 | - |
|
195 | - function displayPage($data = array()) |
|
196 | - { |
|
197 | - $title = ($data['title'] == '') ? 'No title' : $data['title']; |
|
198 | - $message = ($data['message'] == '') ? array('No message') : $data['message']; |
|
199 | - |
|
200 | - $out = ""; |
|
201 | - |
|
202 | - foreach($message as $text) |
|
203 | - { |
|
204 | - if(KSESTEST_ENV == 'WEB') |
|
205 | - { |
|
206 | - $header = "\t\t<h1>$title</h1>\n\t\t<hr />\n"; |
|
207 | - $out .= "\t\t<p>\n"; |
|
208 | - $out .= "\t\t\t$text\n"; |
|
209 | - $out .= "\t\t</p>\n"; |
|
210 | - } |
|
211 | - else |
|
212 | - { |
|
213 | - $header = "$title\n" . str_repeat('-', 60) . "\n\n"; |
|
214 | - $out .= "\t$text\n\n"; |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - if(KSESTEST_ENV == 'WEB') |
|
219 | - { |
|
220 | - echo "<html>\n"; |
|
221 | - echo "\t<head>\n"; |
|
222 | - echo "\t\t<title>$title</title>\n"; |
|
223 | - echo "\t</head>\n"; |
|
224 | - echo "\t<body>\n"; |
|
225 | - echo $header; |
|
226 | - echo $out; |
|
227 | - echo "\t</body>\n"; |
|
228 | - echo "</html>\n"; |
|
229 | - } |
|
230 | - else |
|
231 | - { |
|
232 | - echo $header; |
|
233 | - echo $out; |
|
234 | - } |
|
235 | - } |
|
236 | - |
|
237 | - function output_hr() |
|
238 | - { |
|
239 | - if(KSESTEST_ENV == 'WEB') |
|
240 | - { |
|
241 | - return "\t\t\t<hr />\n"; |
|
242 | - } |
|
243 | - else |
|
244 | - { |
|
245 | - return str_repeat(60, '-') . "\n"; |
|
246 | - } |
|
247 | - } |
|
248 | - |
|
249 | - function output_ul($data = array(), $padding = "") |
|
250 | - { |
|
251 | - if(!is_array($data) || count($data) < 1) |
|
252 | - { |
|
253 | - return ""; |
|
254 | - } |
|
255 | - |
|
256 | - $text = ""; |
|
257 | - if(KSESTEST_ENV == 'WEB') |
|
258 | - { |
|
259 | - $text = "\t\t\t<ul>\n"; |
|
260 | - foreach($data as $li) |
|
261 | - { |
|
262 | - $text .= "\t\t\t\t<li>$li</li>\n"; |
|
263 | - } |
|
264 | - $text .= "\t\t\t</ul>\n"; |
|
265 | - } |
|
266 | - else |
|
267 | - { |
|
268 | - foreach($data as $li) |
|
269 | - { |
|
270 | - $text .= $padding . " * $li\n"; |
|
271 | - } |
|
272 | - } |
|
273 | - |
|
274 | - return $text; |
|
275 | - } |
|
276 | - |
|
277 | - function test1_protocols(&$myKses) |
|
278 | - { |
|
279 | - $default_prots = $myKses->dumpProtocols(); |
|
280 | - $out_text = array(); |
|
281 | - if(count($default_prots) > 0) |
|
282 | - { |
|
283 | - array_push($out_text, "Initial protocols from KSES" . KSESTEST_VER . ":"); |
|
284 | - array_push($out_text, output_ul($default_prots)); |
|
285 | - array_push($out_text, output_hr()); |
|
286 | - } |
|
287 | - |
|
288 | - $myKses->AddProtocols(array("proto1", "proto2:", "proto3")); // Add a list of protocols |
|
289 | - $myKses->AddProtocols("proto4:"); // Add a single protocol (Note ':' is optional at end) |
|
290 | - $myKses->AddProtocol("proto9", "mystery:", "anarchy"); |
|
291 | - $myKses->AddProtocol("alpha", "beta", "gamma:"); |
|
292 | - |
|
293 | - $add_protocol = "\t\t\t<ol>\n"; |
|
294 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols(array("proto1", "proto2:", "proto3"));</li>' . "\n"; |
|
295 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols("proto4:");</li>' . "\n"; |
|
296 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols("proto4:");</li>' . "\n"; |
|
297 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocol("proto9", "mystery:", "anarchy");</li>' . "\n"; |
|
298 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocol("alpha", "beta", "gamma:");</li>' . "\n"; |
|
299 | - $add_protocol .= "\t\t\t</ol>\n"; |
|
300 | - |
|
301 | - array_push($out_text, $add_protocol); |
|
302 | - |
|
303 | - $new_prots = $myKses->dumpProtocols(); |
|
304 | - if(count($new_prots) > 0) |
|
305 | - { |
|
306 | - array_push($out_text, "New protocols from KSES" . KSESTEST_VER . " after using AddProtocol(s):"); |
|
307 | - array_push($out_text, output_ul($new_prots)); |
|
308 | - array_push($out_text, output_hr()); |
|
309 | - } |
|
310 | - |
|
311 | - $myKses->RemoveProtocols(array("mystery", "anarchy:")); |
|
312 | - $myKses->RemoveProtocols("alpha:"); |
|
313 | - $myKses->RemoveProtocol("beta:"); |
|
314 | - $myKses->RemoveProtocol("gamma"); |
|
315 | - |
|
316 | - $remove_protocol = "\t\t\t<ol>\n"; |
|
317 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocols(array("mystery", "anarchy:"));</li>' . "\n"; |
|
318 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocols("alpha:");</li>' . "\n"; |
|
319 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocol("beta:");</li>' . "\n"; |
|
320 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocol("gamma");</li>' . "\n"; |
|
321 | - $remove_protocol .= "\t\t\t</ol>\n"; |
|
322 | - array_push($out_text, $remove_protocol); |
|
323 | - |
|
324 | - $new_prots = $myKses->dumpProtocols(); |
|
325 | - if(count($new_prots) > 0) |
|
326 | - { |
|
327 | - array_push($out_text, "Resulting protocols from KSES" . KSESTEST_VER . " after using RemoveProtocol(s):"); |
|
328 | - array_push($out_text, output_ul($new_prots)); |
|
329 | - array_push($out_text, output_hr()); |
|
330 | - } |
|
331 | - |
|
332 | - $myKses->SetProtocols(array("https", "gopher", "news")); |
|
333 | - $set_protocol = "\t\t\t<ol>\n"; |
|
334 | - $set_protocol .= "\t\t\t\t" . '<li>$myKses->SetProtocols(array("https", "gopher", "news"));</li>' . "\n"; |
|
335 | - $set_protocol .= "\t\t\t</ol>\n"; |
|
336 | - array_push($out_text, $set_protocol); |
|
337 | - |
|
338 | - $new_prots = $myKses->dumpProtocols(); |
|
339 | - if(count($new_prots) > 0) |
|
340 | - { |
|
341 | - array_push($out_text, "Resulting protocols from KSES" . KSESTEST_VER . " after using SetProtocols:"); |
|
342 | - array_push($out_text, output_ul($new_prots)); |
|
343 | - array_push($out_text, output_hr()); |
|
344 | - } |
|
345 | - |
|
346 | - // Invisible reset |
|
347 | - $myKses->SetProtocols(array("http", "proto1", "proto2", "proto9")); |
|
348 | - |
|
349 | - return $out_text; |
|
350 | - } |
|
351 | - |
|
352 | - function test1_html(&$myKses) |
|
353 | - { |
|
354 | - $out = array(); |
|
355 | - |
|
356 | - // Allows <p>|</p> tag |
|
357 | - $myKses->AddHTML("p"); |
|
358 | - |
|
359 | - // Allows 'a' tag with href|name attributes, |
|
360 | - // href has minlen of 10 chars, and maxlen of 25 chars |
|
361 | - // name has minlen of 2 chars |
|
362 | - $myKses->AddHTML( |
|
363 | - "a", |
|
364 | - array( |
|
365 | - "href" => array('maxlen' => 25, 'minlen' => 10), |
|
366 | - "name" => array('minlen' => 2) |
|
367 | - ) |
|
368 | - ); |
|
369 | - |
|
370 | - // Allows 'td' tag with colspan|rowspan|class|style|width|nowrap attributes, |
|
371 | - // colspan has minval of 2 and maxval of 5 |
|
372 | - // rowspan has minval of 3 and maxval of 6 |
|
373 | - // class has minlen of 1 char and maxlen of 10 chars |
|
374 | - // style has minlen of 10 chars and maxlen of 100 chars |
|
375 | - // width has maxval of 100 |
|
376 | - // nowrap is valueless |
|
377 | - $myKses->AddHTML( |
|
378 | - "td", |
|
379 | - array( |
|
380 | - "colspan" => array('minval' => 2, 'maxval' => 5), |
|
381 | - "rowspan" => array('minval' => 3, 'maxval' => 6), |
|
382 | - "class" => array("minlen" => 1, 'maxlen' => 10), |
|
383 | - "width" => array("maxval" => 100), |
|
384 | - "style" => array('minlen' => 10, 'maxlen' => 100), |
|
385 | - "nowrap" => array('valueless' => 'y') |
|
386 | - ) |
|
387 | - ); |
|
388 | - |
|
389 | - array_push($out, "Modifying HTML Tests:"); |
|
390 | - $code_text = "<pre>\n"; |
|
391 | - $code_text .= " // Allows <p>|</p> tag\n"; |
|
392 | - $code_text .= " \$myKses->AddHTML(\"p\");\n"; |
|
393 | - $code_text .= "\n"; |
|
394 | - $code_text .= " // Allows 'a' tag with href|name attributes,\n"; |
|
395 | - $code_text .= " // href has minlen of 10 chars, and maxlen of 25 chars\n"; |
|
396 | - $code_text .= " // name has minlen of 2 chars\n"; |
|
397 | - $code_text .= " \$myKses->AddHTML(\n"; |
|
398 | - $code_text .= " \"a\",\n"; |
|
399 | - $code_text .= " array(\n"; |
|
400 | - $code_text .= " \"href\" => array('maxlen' => 25, 'minlen' => 10),\n"; |
|
401 | - $code_text .= " \"name\" => array('minlen' => 2)\n"; |
|
402 | - $code_text .= " )\n"; |
|
403 | - $code_text .= " );\n"; |
|
404 | - $code_text .= "\n"; |
|
405 | - $code_text .= " // Allows 'td' tag with colspan|rowspan|class|style|width|nowrap attributes,\n"; |
|
406 | - $code_text .= " // colspan has minval of 2 and maxval of 5\n"; |
|
407 | - $code_text .= " // rowspan has minval of 3 and maxval of 6\n"; |
|
408 | - $code_text .= " // class has minlen of 1 char and maxlen of 10 chars\n"; |
|
409 | - $code_text .= " // style has minlen of 10 chars and maxlen of 100 chars\n"; |
|
410 | - $code_text .= " // width has maxval of 100\n"; |
|
411 | - $code_text .= " // nowrap is valueless\n"; |
|
412 | - $code_text .= " \$myKses->AddHTML(\n"; |
|
413 | - $code_text .= " \"td\",\n"; |
|
414 | - $code_text .= " array(\n"; |
|
415 | - $code_text .= " \"colspan\" => array('minval' => 2, 'maxval' => 5),\n"; |
|
416 | - $code_text .= " \"rowspan\" => array('minval' => 3, 'maxval' => 6),\n"; |
|
417 | - $code_text .= " \"class\" => array(\"minlen\" => 1, 'maxlen' => 10),\n"; |
|
418 | - $code_text .= " \"width\" => array(\"maxval\" => 100),\n"; |
|
419 | - $code_text .= " \"style\" => array('minlen' => 10, 'maxlen' => 100),\n"; |
|
420 | - $code_text .= " \"nowrap\" => array('valueless' => 'y')\n"; |
|
421 | - $code_text .= " )\n"; |
|
422 | - $code_text .= " );\n"; |
|
423 | - $code_text .= "</pre>\n"; |
|
424 | - |
|
425 | - array_push($out, $code_text); |
|
426 | - array_push($out, output_hr()); |
|
427 | - array_push($out, "Net results:"); |
|
428 | - |
|
429 | - $out_elems = $myKses->DumpElements(); |
|
430 | - if(count($out_elems) > 0) |
|
431 | - { |
|
432 | - //array_push($out, "\t\t\t<ul>\n"); |
|
433 | - foreach($out_elems as $tag => $attr_data) |
|
434 | - { |
|
435 | - $out_li_elems = array(); |
|
436 | - $elem_text = "(X)HTML element $tag"; |
|
437 | - $allow = ""; |
|
438 | - if(isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
439 | - { |
|
440 | - $allow = " allows attribute"; |
|
441 | - if(count($attr_data) > 1) |
|
442 | - { |
|
443 | - $allow .= "s"; |
|
444 | - } |
|
445 | - $allow .= ":\n"; |
|
446 | - } |
|
447 | - |
|
448 | - array_push($out_li_elems, "$elem_text$allow"); |
|
449 | - |
|
450 | - $attr_test_li = array(); |
|
451 | - if(isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
452 | - { |
|
453 | - foreach($attr_data as $attr_name => $attr_tests) |
|
454 | - { |
|
455 | - $li_text = $attr_name; |
|
456 | - if(isset($attr_tests) && count($attr_tests) > 0) |
|
457 | - { |
|
458 | - foreach($attr_tests as $test_name => $test_val) |
|
459 | - { |
|
460 | - switch($test_name) |
|
461 | - { |
|
462 | - case "maxlen": |
|
463 | - $li_text .= " - maximum length of '" . $test_val . "' characters"; |
|
464 | - break; |
|
465 | - case "minlen": |
|
466 | - $li_text .= " - minimum length of '" . $test_val . "' characters"; |
|
467 | - break; |
|
468 | - case "minval": |
|
469 | - $li_text .= " - minimum value of '" . $test_val . "'"; |
|
470 | - break; |
|
471 | - case "maxval": |
|
472 | - $li_text .= " - maximum value of '" . $test_val . "'"; |
|
473 | - break; |
|
474 | - case "valueless": |
|
475 | - switch(strtolower($test_val)) |
|
476 | - { |
|
477 | - case 'n': |
|
478 | - $li_text .= " - must not be valueless"; |
|
479 | - break; |
|
480 | - case 'y': |
|
481 | - $li_text .= " - must be valueless"; |
|
482 | - break; |
|
483 | - default: |
|
484 | - break; |
|
485 | - } |
|
486 | - break; |
|
487 | - default: |
|
488 | - break; |
|
489 | - } |
|
490 | - } |
|
491 | - } |
|
492 | - array_push($attr_test_li, $li_text); |
|
493 | - } |
|
494 | - if(count($attr_test_li) > 0) |
|
495 | - { |
|
496 | - $attr_test_li = output_ul($attr_test_li, " "); |
|
497 | - $out_li_elems = array("$elem_text$allow$attr_test_li"); |
|
498 | - } |
|
499 | - } |
|
500 | - $out = array_merge($out, $out_li_elems); |
|
501 | - } |
|
502 | - } |
|
503 | - |
|
504 | - return $out; |
|
505 | - } |
|
3 | + // This is a q&d program that shows some of the results of |
|
4 | + // running KSES. If you have further questions, check the |
|
5 | + // current valid email address at http://chaos.org/contact/ |
|
6 | + |
|
7 | + // Make sure we're in a usable PHP environment |
|
8 | + if(substr(phpversion(), 0, 1) < 4) |
|
9 | + { |
|
10 | + define('KSESTEST_VER', 0); |
|
11 | + } |
|
12 | + elseif(substr(phpversion(), 0, 1) >= 5) |
|
13 | + { |
|
14 | + define('KSESTEST_VER', 5); |
|
15 | + } |
|
16 | + else |
|
17 | + { |
|
18 | + define('KSESTEST_VER', 4); |
|
19 | + } |
|
20 | + |
|
21 | + // See if we're in command line or web |
|
22 | + if($_SERVER["DOCUMENT_ROOT"] == "") |
|
23 | + { |
|
24 | + define('KSESTEST_ENV', 'CLI'); |
|
25 | + } |
|
26 | + else |
|
27 | + { |
|
28 | + define('KSESTEST_ENV', 'WEB'); |
|
29 | + } |
|
30 | + |
|
31 | + if(KSESTEST_VER == 0) |
|
32 | + { |
|
33 | + $message = array( |
|
34 | + "Error: Not using a current version of PHP!", |
|
35 | + "You are using PHP version " . phpversion() . ".", |
|
36 | + "KSES Class version requires PHP4 or better.", |
|
37 | + "KSES test program ending." |
|
38 | + ); |
|
39 | + |
|
40 | + displayPage( |
|
41 | + array("title" => "Error running KSES test", "message" => $message) |
|
42 | + ); |
|
43 | + |
|
44 | + exit(); |
|
45 | + } |
|
46 | + |
|
47 | + $include_file = "php" . KSESTEST_VER . ".class.kses.php"; |
|
48 | + if(file_exists($include_file) && is_readable($include_file)) |
|
49 | + { |
|
50 | + include_once($include_file); |
|
51 | + } |
|
52 | + else |
|
53 | + { |
|
54 | + $message = array( |
|
55 | + "Error: Unable to find '" . $include_file . "'.", |
|
56 | + "Please check your include path and make sure the file is available.", |
|
57 | + "Path: " . ini_get('include_path') |
|
58 | + ); |
|
59 | + |
|
60 | + displayPage( |
|
61 | + array('title' => 'Unable to include ' . $include_file, 'message' => $message) |
|
62 | + ); |
|
63 | + |
|
64 | + exit(); |
|
65 | + } |
|
66 | + |
|
67 | + $kses_type = "kses" . KSESTEST_VER; |
|
68 | + $myKses = new $kses_type; |
|
69 | + |
|
70 | + $test_text = array(); |
|
71 | + $test_text = test1_protocols($myKses); |
|
72 | + $test_text = array_merge($test_text, test1_html($myKses)); |
|
73 | + $test_text = array_merge($test_text, test1_kses($myKses)); |
|
74 | + |
|
75 | + displayPage( |
|
76 | + array('title' => 'New Test', 'message' => $test_text) |
|
77 | + ); |
|
78 | + |
|
79 | + function test1_kses(&$myKses) |
|
80 | + { |
|
81 | + $out = array(output_hr(), "Testing current configuration"); |
|
82 | + |
|
83 | + $test_tags = array( |
|
84 | + '<a href="http://www.chaos.org/">www.chaos.org</a>', |
|
85 | + '<a name="X">Short \'a name\' tag</a>', |
|
86 | + '<td colspan="3" rowspan="5">Foo</td>', |
|
87 | + '<td rowspan="2" class="mugwump" style="background-color: rgb(255, 204 204);">Bar</td>', |
|
88 | + '<td nowrap>Very Long String running to 1000 characters...</td>', |
|
89 | + '<td bgcolor="#00ff00" nowrap>Very Long String with a blue background</td>', |
|
90 | + '<a href="proto1://www.foo.com">New protocol test</a>', |
|
91 | + '<img src="proto2://www.foo.com" />', |
|
92 | + '<a href="javascript:javascript:javascript:javascript:javascript:alert(\'Boo!\');">bleep</a>', |
|
93 | + '<a href="proto4://abc.xyz.foo.com">Another new protocol</a>', |
|
94 | + '<a href="proto9://foo.foo.foo.foo.foo.org/">Test of "proto9"</a>', |
|
95 | + '<td width="75">Bar!</td>', |
|
96 | + '<td width="200">Long Cell</td>' |
|
97 | + ); |
|
98 | + |
|
99 | + $out_li = array(); |
|
100 | + // Keep only allowed HTML from the presumed 'form'. |
|
101 | + foreach($test_tags as $tag) |
|
102 | + { |
|
103 | + $temp = $myKses->Parse($tag); |
|
104 | + $check = ($temp == $tag) ? true : false; |
|
105 | + $text = ($temp == $tag) ? 'pass' : 'fail'; |
|
106 | + |
|
107 | + $li_text = output_testresult($check, $text) . output_newline(); |
|
108 | + $li_text .= "Input: " . output_translate($tag) . output_newline(); |
|
109 | + $li_text .= "Output: " . output_translate($temp); |
|
110 | + if(KSESTEST_ENV == 'CLI') |
|
111 | + { |
|
112 | + $li_text .= output_newline(); |
|
113 | + } |
|
114 | + |
|
115 | + array_push($out_li, output_code_wrap($li_text)); |
|
116 | + } |
|
117 | + |
|
118 | + $out = array_merge($out, array(output_ul($out_li))); |
|
119 | + array_push($out, output_hr()); |
|
120 | + array_push($out, "Testing is now finished."); |
|
121 | + return $out; |
|
122 | + } |
|
123 | + |
|
124 | + function output_code_wrap($text) |
|
125 | + { |
|
126 | + if(KSESTEST_ENV == 'CLI') |
|
127 | + { |
|
128 | + return $text; |
|
129 | + } |
|
130 | + else |
|
131 | + { |
|
132 | + return "<code>\n$text<code>\n"; |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + function output_translate($text) |
|
137 | + { |
|
138 | + if(KSESTEST_ENV == 'CLI') |
|
139 | + { |
|
140 | + return $text; |
|
141 | + } |
|
142 | + else |
|
143 | + { |
|
144 | + return htmlentities($text); |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + function output_testresult($pass = false, $text = "") |
|
149 | + { |
|
150 | + if(KSESTEST_ENV == 'CLI') |
|
151 | + { |
|
152 | + return '[' . $text . ']'; |
|
153 | + } |
|
154 | + else |
|
155 | + { |
|
156 | + if($pass == true) |
|
157 | + { |
|
158 | + return '<span style="color: green;">[' . $text . ']</span>'; |
|
159 | + } |
|
160 | + else |
|
161 | + { |
|
162 | + return '<span style="color: red;">[' . $text . ']</span>'; |
|
163 | + } |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + function output_spaces() |
|
168 | + { |
|
169 | + if(KSESTEST_ENV == 'WEB') |
|
170 | + { |
|
171 | + $out = " "; |
|
172 | + } |
|
173 | + else |
|
174 | + { |
|
175 | + $out = " "; |
|
176 | + } |
|
177 | + |
|
178 | + return $out; |
|
179 | + } |
|
180 | + |
|
181 | + function output_newline() |
|
182 | + { |
|
183 | + if(KSESTEST_ENV == 'WEB') |
|
184 | + { |
|
185 | + $out = "<br />\n"; |
|
186 | + } |
|
187 | + else |
|
188 | + { |
|
189 | + $out = "\n"; |
|
190 | + } |
|
191 | + |
|
192 | + return $out; |
|
193 | + } |
|
194 | + |
|
195 | + function displayPage($data = array()) |
|
196 | + { |
|
197 | + $title = ($data['title'] == '') ? 'No title' : $data['title']; |
|
198 | + $message = ($data['message'] == '') ? array('No message') : $data['message']; |
|
199 | + |
|
200 | + $out = ""; |
|
201 | + |
|
202 | + foreach($message as $text) |
|
203 | + { |
|
204 | + if(KSESTEST_ENV == 'WEB') |
|
205 | + { |
|
206 | + $header = "\t\t<h1>$title</h1>\n\t\t<hr />\n"; |
|
207 | + $out .= "\t\t<p>\n"; |
|
208 | + $out .= "\t\t\t$text\n"; |
|
209 | + $out .= "\t\t</p>\n"; |
|
210 | + } |
|
211 | + else |
|
212 | + { |
|
213 | + $header = "$title\n" . str_repeat('-', 60) . "\n\n"; |
|
214 | + $out .= "\t$text\n\n"; |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + if(KSESTEST_ENV == 'WEB') |
|
219 | + { |
|
220 | + echo "<html>\n"; |
|
221 | + echo "\t<head>\n"; |
|
222 | + echo "\t\t<title>$title</title>\n"; |
|
223 | + echo "\t</head>\n"; |
|
224 | + echo "\t<body>\n"; |
|
225 | + echo $header; |
|
226 | + echo $out; |
|
227 | + echo "\t</body>\n"; |
|
228 | + echo "</html>\n"; |
|
229 | + } |
|
230 | + else |
|
231 | + { |
|
232 | + echo $header; |
|
233 | + echo $out; |
|
234 | + } |
|
235 | + } |
|
236 | + |
|
237 | + function output_hr() |
|
238 | + { |
|
239 | + if(KSESTEST_ENV == 'WEB') |
|
240 | + { |
|
241 | + return "\t\t\t<hr />\n"; |
|
242 | + } |
|
243 | + else |
|
244 | + { |
|
245 | + return str_repeat(60, '-') . "\n"; |
|
246 | + } |
|
247 | + } |
|
248 | + |
|
249 | + function output_ul($data = array(), $padding = "") |
|
250 | + { |
|
251 | + if(!is_array($data) || count($data) < 1) |
|
252 | + { |
|
253 | + return ""; |
|
254 | + } |
|
255 | + |
|
256 | + $text = ""; |
|
257 | + if(KSESTEST_ENV == 'WEB') |
|
258 | + { |
|
259 | + $text = "\t\t\t<ul>\n"; |
|
260 | + foreach($data as $li) |
|
261 | + { |
|
262 | + $text .= "\t\t\t\t<li>$li</li>\n"; |
|
263 | + } |
|
264 | + $text .= "\t\t\t</ul>\n"; |
|
265 | + } |
|
266 | + else |
|
267 | + { |
|
268 | + foreach($data as $li) |
|
269 | + { |
|
270 | + $text .= $padding . " * $li\n"; |
|
271 | + } |
|
272 | + } |
|
273 | + |
|
274 | + return $text; |
|
275 | + } |
|
276 | + |
|
277 | + function test1_protocols(&$myKses) |
|
278 | + { |
|
279 | + $default_prots = $myKses->dumpProtocols(); |
|
280 | + $out_text = array(); |
|
281 | + if(count($default_prots) > 0) |
|
282 | + { |
|
283 | + array_push($out_text, "Initial protocols from KSES" . KSESTEST_VER . ":"); |
|
284 | + array_push($out_text, output_ul($default_prots)); |
|
285 | + array_push($out_text, output_hr()); |
|
286 | + } |
|
287 | + |
|
288 | + $myKses->AddProtocols(array("proto1", "proto2:", "proto3")); // Add a list of protocols |
|
289 | + $myKses->AddProtocols("proto4:"); // Add a single protocol (Note ':' is optional at end) |
|
290 | + $myKses->AddProtocol("proto9", "mystery:", "anarchy"); |
|
291 | + $myKses->AddProtocol("alpha", "beta", "gamma:"); |
|
292 | + |
|
293 | + $add_protocol = "\t\t\t<ol>\n"; |
|
294 | + $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols(array("proto1", "proto2:", "proto3"));</li>' . "\n"; |
|
295 | + $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols("proto4:");</li>' . "\n"; |
|
296 | + $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols("proto4:");</li>' . "\n"; |
|
297 | + $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocol("proto9", "mystery:", "anarchy");</li>' . "\n"; |
|
298 | + $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocol("alpha", "beta", "gamma:");</li>' . "\n"; |
|
299 | + $add_protocol .= "\t\t\t</ol>\n"; |
|
300 | + |
|
301 | + array_push($out_text, $add_protocol); |
|
302 | + |
|
303 | + $new_prots = $myKses->dumpProtocols(); |
|
304 | + if(count($new_prots) > 0) |
|
305 | + { |
|
306 | + array_push($out_text, "New protocols from KSES" . KSESTEST_VER . " after using AddProtocol(s):"); |
|
307 | + array_push($out_text, output_ul($new_prots)); |
|
308 | + array_push($out_text, output_hr()); |
|
309 | + } |
|
310 | + |
|
311 | + $myKses->RemoveProtocols(array("mystery", "anarchy:")); |
|
312 | + $myKses->RemoveProtocols("alpha:"); |
|
313 | + $myKses->RemoveProtocol("beta:"); |
|
314 | + $myKses->RemoveProtocol("gamma"); |
|
315 | + |
|
316 | + $remove_protocol = "\t\t\t<ol>\n"; |
|
317 | + $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocols(array("mystery", "anarchy:"));</li>' . "\n"; |
|
318 | + $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocols("alpha:");</li>' . "\n"; |
|
319 | + $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocol("beta:");</li>' . "\n"; |
|
320 | + $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocol("gamma");</li>' . "\n"; |
|
321 | + $remove_protocol .= "\t\t\t</ol>\n"; |
|
322 | + array_push($out_text, $remove_protocol); |
|
323 | + |
|
324 | + $new_prots = $myKses->dumpProtocols(); |
|
325 | + if(count($new_prots) > 0) |
|
326 | + { |
|
327 | + array_push($out_text, "Resulting protocols from KSES" . KSESTEST_VER . " after using RemoveProtocol(s):"); |
|
328 | + array_push($out_text, output_ul($new_prots)); |
|
329 | + array_push($out_text, output_hr()); |
|
330 | + } |
|
331 | + |
|
332 | + $myKses->SetProtocols(array("https", "gopher", "news")); |
|
333 | + $set_protocol = "\t\t\t<ol>\n"; |
|
334 | + $set_protocol .= "\t\t\t\t" . '<li>$myKses->SetProtocols(array("https", "gopher", "news"));</li>' . "\n"; |
|
335 | + $set_protocol .= "\t\t\t</ol>\n"; |
|
336 | + array_push($out_text, $set_protocol); |
|
337 | + |
|
338 | + $new_prots = $myKses->dumpProtocols(); |
|
339 | + if(count($new_prots) > 0) |
|
340 | + { |
|
341 | + array_push($out_text, "Resulting protocols from KSES" . KSESTEST_VER . " after using SetProtocols:"); |
|
342 | + array_push($out_text, output_ul($new_prots)); |
|
343 | + array_push($out_text, output_hr()); |
|
344 | + } |
|
345 | + |
|
346 | + // Invisible reset |
|
347 | + $myKses->SetProtocols(array("http", "proto1", "proto2", "proto9")); |
|
348 | + |
|
349 | + return $out_text; |
|
350 | + } |
|
351 | + |
|
352 | + function test1_html(&$myKses) |
|
353 | + { |
|
354 | + $out = array(); |
|
355 | + |
|
356 | + // Allows <p>|</p> tag |
|
357 | + $myKses->AddHTML("p"); |
|
358 | + |
|
359 | + // Allows 'a' tag with href|name attributes, |
|
360 | + // href has minlen of 10 chars, and maxlen of 25 chars |
|
361 | + // name has minlen of 2 chars |
|
362 | + $myKses->AddHTML( |
|
363 | + "a", |
|
364 | + array( |
|
365 | + "href" => array('maxlen' => 25, 'minlen' => 10), |
|
366 | + "name" => array('minlen' => 2) |
|
367 | + ) |
|
368 | + ); |
|
369 | + |
|
370 | + // Allows 'td' tag with colspan|rowspan|class|style|width|nowrap attributes, |
|
371 | + // colspan has minval of 2 and maxval of 5 |
|
372 | + // rowspan has minval of 3 and maxval of 6 |
|
373 | + // class has minlen of 1 char and maxlen of 10 chars |
|
374 | + // style has minlen of 10 chars and maxlen of 100 chars |
|
375 | + // width has maxval of 100 |
|
376 | + // nowrap is valueless |
|
377 | + $myKses->AddHTML( |
|
378 | + "td", |
|
379 | + array( |
|
380 | + "colspan" => array('minval' => 2, 'maxval' => 5), |
|
381 | + "rowspan" => array('minval' => 3, 'maxval' => 6), |
|
382 | + "class" => array("minlen" => 1, 'maxlen' => 10), |
|
383 | + "width" => array("maxval" => 100), |
|
384 | + "style" => array('minlen' => 10, 'maxlen' => 100), |
|
385 | + "nowrap" => array('valueless' => 'y') |
|
386 | + ) |
|
387 | + ); |
|
388 | + |
|
389 | + array_push($out, "Modifying HTML Tests:"); |
|
390 | + $code_text = "<pre>\n"; |
|
391 | + $code_text .= " // Allows <p>|</p> tag\n"; |
|
392 | + $code_text .= " \$myKses->AddHTML(\"p\");\n"; |
|
393 | + $code_text .= "\n"; |
|
394 | + $code_text .= " // Allows 'a' tag with href|name attributes,\n"; |
|
395 | + $code_text .= " // href has minlen of 10 chars, and maxlen of 25 chars\n"; |
|
396 | + $code_text .= " // name has minlen of 2 chars\n"; |
|
397 | + $code_text .= " \$myKses->AddHTML(\n"; |
|
398 | + $code_text .= " \"a\",\n"; |
|
399 | + $code_text .= " array(\n"; |
|
400 | + $code_text .= " \"href\" => array('maxlen' => 25, 'minlen' => 10),\n"; |
|
401 | + $code_text .= " \"name\" => array('minlen' => 2)\n"; |
|
402 | + $code_text .= " )\n"; |
|
403 | + $code_text .= " );\n"; |
|
404 | + $code_text .= "\n"; |
|
405 | + $code_text .= " // Allows 'td' tag with colspan|rowspan|class|style|width|nowrap attributes,\n"; |
|
406 | + $code_text .= " // colspan has minval of 2 and maxval of 5\n"; |
|
407 | + $code_text .= " // rowspan has minval of 3 and maxval of 6\n"; |
|
408 | + $code_text .= " // class has minlen of 1 char and maxlen of 10 chars\n"; |
|
409 | + $code_text .= " // style has minlen of 10 chars and maxlen of 100 chars\n"; |
|
410 | + $code_text .= " // width has maxval of 100\n"; |
|
411 | + $code_text .= " // nowrap is valueless\n"; |
|
412 | + $code_text .= " \$myKses->AddHTML(\n"; |
|
413 | + $code_text .= " \"td\",\n"; |
|
414 | + $code_text .= " array(\n"; |
|
415 | + $code_text .= " \"colspan\" => array('minval' => 2, 'maxval' => 5),\n"; |
|
416 | + $code_text .= " \"rowspan\" => array('minval' => 3, 'maxval' => 6),\n"; |
|
417 | + $code_text .= " \"class\" => array(\"minlen\" => 1, 'maxlen' => 10),\n"; |
|
418 | + $code_text .= " \"width\" => array(\"maxval\" => 100),\n"; |
|
419 | + $code_text .= " \"style\" => array('minlen' => 10, 'maxlen' => 100),\n"; |
|
420 | + $code_text .= " \"nowrap\" => array('valueless' => 'y')\n"; |
|
421 | + $code_text .= " )\n"; |
|
422 | + $code_text .= " );\n"; |
|
423 | + $code_text .= "</pre>\n"; |
|
424 | + |
|
425 | + array_push($out, $code_text); |
|
426 | + array_push($out, output_hr()); |
|
427 | + array_push($out, "Net results:"); |
|
428 | + |
|
429 | + $out_elems = $myKses->DumpElements(); |
|
430 | + if(count($out_elems) > 0) |
|
431 | + { |
|
432 | + //array_push($out, "\t\t\t<ul>\n"); |
|
433 | + foreach($out_elems as $tag => $attr_data) |
|
434 | + { |
|
435 | + $out_li_elems = array(); |
|
436 | + $elem_text = "(X)HTML element $tag"; |
|
437 | + $allow = ""; |
|
438 | + if(isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
439 | + { |
|
440 | + $allow = " allows attribute"; |
|
441 | + if(count($attr_data) > 1) |
|
442 | + { |
|
443 | + $allow .= "s"; |
|
444 | + } |
|
445 | + $allow .= ":\n"; |
|
446 | + } |
|
447 | + |
|
448 | + array_push($out_li_elems, "$elem_text$allow"); |
|
449 | + |
|
450 | + $attr_test_li = array(); |
|
451 | + if(isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
452 | + { |
|
453 | + foreach($attr_data as $attr_name => $attr_tests) |
|
454 | + { |
|
455 | + $li_text = $attr_name; |
|
456 | + if(isset($attr_tests) && count($attr_tests) > 0) |
|
457 | + { |
|
458 | + foreach($attr_tests as $test_name => $test_val) |
|
459 | + { |
|
460 | + switch($test_name) |
|
461 | + { |
|
462 | + case "maxlen": |
|
463 | + $li_text .= " - maximum length of '" . $test_val . "' characters"; |
|
464 | + break; |
|
465 | + case "minlen": |
|
466 | + $li_text .= " - minimum length of '" . $test_val . "' characters"; |
|
467 | + break; |
|
468 | + case "minval": |
|
469 | + $li_text .= " - minimum value of '" . $test_val . "'"; |
|
470 | + break; |
|
471 | + case "maxval": |
|
472 | + $li_text .= " - maximum value of '" . $test_val . "'"; |
|
473 | + break; |
|
474 | + case "valueless": |
|
475 | + switch(strtolower($test_val)) |
|
476 | + { |
|
477 | + case 'n': |
|
478 | + $li_text .= " - must not be valueless"; |
|
479 | + break; |
|
480 | + case 'y': |
|
481 | + $li_text .= " - must be valueless"; |
|
482 | + break; |
|
483 | + default: |
|
484 | + break; |
|
485 | + } |
|
486 | + break; |
|
487 | + default: |
|
488 | + break; |
|
489 | + } |
|
490 | + } |
|
491 | + } |
|
492 | + array_push($attr_test_li, $li_text); |
|
493 | + } |
|
494 | + if(count($attr_test_li) > 0) |
|
495 | + { |
|
496 | + $attr_test_li = output_ul($attr_test_li, " "); |
|
497 | + $out_li_elems = array("$elem_text$allow$attr_test_li"); |
|
498 | + } |
|
499 | + } |
|
500 | + $out = array_merge($out, $out_li_elems); |
|
501 | + } |
|
502 | + } |
|
503 | + |
|
504 | + return $out; |
|
505 | + } |
|
506 | 506 | |
507 | 507 | ?> |
508 | 508 | \ No newline at end of file |
@@ -5,11 +5,11 @@ discard block |
||
5 | 5 | // current valid email address at http://chaos.org/contact/ |
6 | 6 | |
7 | 7 | // Make sure we're in a usable PHP environment |
8 | - if(substr(phpversion(), 0, 1) < 4) |
|
8 | + if (substr(phpversion(), 0, 1) < 4) |
|
9 | 9 | { |
10 | 10 | define('KSESTEST_VER', 0); |
11 | 11 | } |
12 | - elseif(substr(phpversion(), 0, 1) >= 5) |
|
12 | + elseif (substr(phpversion(), 0, 1) >= 5) |
|
13 | 13 | { |
14 | 14 | define('KSESTEST_VER', 5); |
15 | 15 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | // See if we're in command line or web |
22 | - if($_SERVER["DOCUMENT_ROOT"] == "") |
|
22 | + if ($_SERVER["DOCUMENT_ROOT"] == "") |
|
23 | 23 | { |
24 | 24 | define('KSESTEST_ENV', 'CLI'); |
25 | 25 | } |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | define('KSESTEST_ENV', 'WEB'); |
29 | 29 | } |
30 | 30 | |
31 | - if(KSESTEST_VER == 0) |
|
31 | + if (KSESTEST_VER == 0) |
|
32 | 32 | { |
33 | 33 | $message = array( |
34 | 34 | "Error: Not using a current version of PHP!", |
35 | - "You are using PHP version " . phpversion() . ".", |
|
35 | + "You are using PHP version ".phpversion().".", |
|
36 | 36 | "KSES Class version requires PHP4 or better.", |
37 | 37 | "KSES test program ending." |
38 | 38 | ); |
@@ -44,27 +44,27 @@ discard block |
||
44 | 44 | exit(); |
45 | 45 | } |
46 | 46 | |
47 | - $include_file = "php" . KSESTEST_VER . ".class.kses.php"; |
|
48 | - if(file_exists($include_file) && is_readable($include_file)) |
|
47 | + $include_file = "php".KSESTEST_VER.".class.kses.php"; |
|
48 | + if (file_exists($include_file) && is_readable($include_file)) |
|
49 | 49 | { |
50 | 50 | include_once($include_file); |
51 | 51 | } |
52 | 52 | else |
53 | 53 | { |
54 | 54 | $message = array( |
55 | - "Error: Unable to find '" . $include_file . "'.", |
|
55 | + "Error: Unable to find '".$include_file."'.", |
|
56 | 56 | "Please check your include path and make sure the file is available.", |
57 | - "Path: " . ini_get('include_path') |
|
57 | + "Path: ".ini_get('include_path') |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | displayPage( |
61 | - array('title' => 'Unable to include ' . $include_file, 'message' => $message) |
|
61 | + array('title' => 'Unable to include '.$include_file, 'message' => $message) |
|
62 | 62 | ); |
63 | 63 | |
64 | 64 | exit(); |
65 | 65 | } |
66 | 66 | |
67 | - $kses_type = "kses" . KSESTEST_VER; |
|
67 | + $kses_type = "kses".KSESTEST_VER; |
|
68 | 68 | $myKses = new $kses_type; |
69 | 69 | |
70 | 70 | $test_text = array(); |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | |
99 | 99 | $out_li = array(); |
100 | 100 | // Keep only allowed HTML from the presumed 'form'. |
101 | - foreach($test_tags as $tag) |
|
101 | + foreach ($test_tags as $tag) |
|
102 | 102 | { |
103 | 103 | $temp = $myKses->Parse($tag); |
104 | 104 | $check = ($temp == $tag) ? true : false; |
105 | 105 | $text = ($temp == $tag) ? 'pass' : 'fail'; |
106 | 106 | |
107 | - $li_text = output_testresult($check, $text) . output_newline(); |
|
108 | - $li_text .= "Input: " . output_translate($tag) . output_newline(); |
|
109 | - $li_text .= "Output: " . output_translate($temp); |
|
110 | - if(KSESTEST_ENV == 'CLI') |
|
107 | + $li_text = output_testresult($check, $text).output_newline(); |
|
108 | + $li_text .= "Input: ".output_translate($tag).output_newline(); |
|
109 | + $li_text .= "Output: ".output_translate($temp); |
|
110 | + if (KSESTEST_ENV == 'CLI') |
|
111 | 111 | { |
112 | 112 | $li_text .= output_newline(); |
113 | 113 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | function output_code_wrap($text) |
125 | 125 | { |
126 | - if(KSESTEST_ENV == 'CLI') |
|
126 | + if (KSESTEST_ENV == 'CLI') |
|
127 | 127 | { |
128 | 128 | return $text; |
129 | 129 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | function output_translate($text) |
137 | 137 | { |
138 | - if(KSESTEST_ENV == 'CLI') |
|
138 | + if (KSESTEST_ENV == 'CLI') |
|
139 | 139 | { |
140 | 140 | return $text; |
141 | 141 | } |
@@ -147,26 +147,26 @@ discard block |
||
147 | 147 | |
148 | 148 | function output_testresult($pass = false, $text = "") |
149 | 149 | { |
150 | - if(KSESTEST_ENV == 'CLI') |
|
150 | + if (KSESTEST_ENV == 'CLI') |
|
151 | 151 | { |
152 | - return '[' . $text . ']'; |
|
152 | + return '['.$text.']'; |
|
153 | 153 | } |
154 | 154 | else |
155 | 155 | { |
156 | - if($pass == true) |
|
156 | + if ($pass == true) |
|
157 | 157 | { |
158 | - return '<span style="color: green;">[' . $text . ']</span>'; |
|
158 | + return '<span style="color: green;">['.$text.']</span>'; |
|
159 | 159 | } |
160 | 160 | else |
161 | 161 | { |
162 | - return '<span style="color: red;">[' . $text . ']</span>'; |
|
162 | + return '<span style="color: red;">['.$text.']</span>'; |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | 167 | function output_spaces() |
168 | 168 | { |
169 | - if(KSESTEST_ENV == 'WEB') |
|
169 | + if (KSESTEST_ENV == 'WEB') |
|
170 | 170 | { |
171 | 171 | $out = " "; |
172 | 172 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | function output_newline() |
182 | 182 | { |
183 | - if(KSESTEST_ENV == 'WEB') |
|
183 | + if (KSESTEST_ENV == 'WEB') |
|
184 | 184 | { |
185 | 185 | $out = "<br />\n"; |
186 | 186 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | |
200 | 200 | $out = ""; |
201 | 201 | |
202 | - foreach($message as $text) |
|
202 | + foreach ($message as $text) |
|
203 | 203 | { |
204 | - if(KSESTEST_ENV == 'WEB') |
|
204 | + if (KSESTEST_ENV == 'WEB') |
|
205 | 205 | { |
206 | 206 | $header = "\t\t<h1>$title</h1>\n\t\t<hr />\n"; |
207 | 207 | $out .= "\t\t<p>\n"; |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | } |
211 | 211 | else |
212 | 212 | { |
213 | - $header = "$title\n" . str_repeat('-', 60) . "\n\n"; |
|
213 | + $header = "$title\n".str_repeat('-', 60)."\n\n"; |
|
214 | 214 | $out .= "\t$text\n\n"; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if(KSESTEST_ENV == 'WEB') |
|
218 | + if (KSESTEST_ENV == 'WEB') |
|
219 | 219 | { |
220 | 220 | echo "<html>\n"; |
221 | 221 | echo "\t<head>\n"; |
@@ -236,28 +236,28 @@ discard block |
||
236 | 236 | |
237 | 237 | function output_hr() |
238 | 238 | { |
239 | - if(KSESTEST_ENV == 'WEB') |
|
239 | + if (KSESTEST_ENV == 'WEB') |
|
240 | 240 | { |
241 | 241 | return "\t\t\t<hr />\n"; |
242 | 242 | } |
243 | 243 | else |
244 | 244 | { |
245 | - return str_repeat(60, '-') . "\n"; |
|
245 | + return str_repeat(60, '-')."\n"; |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | 249 | function output_ul($data = array(), $padding = "") |
250 | 250 | { |
251 | - if(!is_array($data) || count($data) < 1) |
|
251 | + if (!is_array($data) || count($data) < 1) |
|
252 | 252 | { |
253 | 253 | return ""; |
254 | 254 | } |
255 | 255 | |
256 | 256 | $text = ""; |
257 | - if(KSESTEST_ENV == 'WEB') |
|
257 | + if (KSESTEST_ENV == 'WEB') |
|
258 | 258 | { |
259 | 259 | $text = "\t\t\t<ul>\n"; |
260 | - foreach($data as $li) |
|
260 | + foreach ($data as $li) |
|
261 | 261 | { |
262 | 262 | $text .= "\t\t\t\t<li>$li</li>\n"; |
263 | 263 | } |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | } |
266 | 266 | else |
267 | 267 | { |
268 | - foreach($data as $li) |
|
268 | + foreach ($data as $li) |
|
269 | 269 | { |
270 | - $text .= $padding . " * $li\n"; |
|
270 | + $text .= $padding." * $li\n"; |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
@@ -278,32 +278,32 @@ discard block |
||
278 | 278 | { |
279 | 279 | $default_prots = $myKses->dumpProtocols(); |
280 | 280 | $out_text = array(); |
281 | - if(count($default_prots) > 0) |
|
281 | + if (count($default_prots) > 0) |
|
282 | 282 | { |
283 | - array_push($out_text, "Initial protocols from KSES" . KSESTEST_VER . ":"); |
|
283 | + array_push($out_text, "Initial protocols from KSES".KSESTEST_VER.":"); |
|
284 | 284 | array_push($out_text, output_ul($default_prots)); |
285 | 285 | array_push($out_text, output_hr()); |
286 | 286 | } |
287 | 287 | |
288 | - $myKses->AddProtocols(array("proto1", "proto2:", "proto3")); // Add a list of protocols |
|
289 | - $myKses->AddProtocols("proto4:"); // Add a single protocol (Note ':' is optional at end) |
|
288 | + $myKses->AddProtocols(array("proto1", "proto2:", "proto3")); // Add a list of protocols |
|
289 | + $myKses->AddProtocols("proto4:"); // Add a single protocol (Note ':' is optional at end) |
|
290 | 290 | $myKses->AddProtocol("proto9", "mystery:", "anarchy"); |
291 | 291 | $myKses->AddProtocol("alpha", "beta", "gamma:"); |
292 | 292 | |
293 | 293 | $add_protocol = "\t\t\t<ol>\n"; |
294 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols(array("proto1", "proto2:", "proto3"));</li>' . "\n"; |
|
295 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols("proto4:");</li>' . "\n"; |
|
296 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocols("proto4:");</li>' . "\n"; |
|
297 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocol("proto9", "mystery:", "anarchy");</li>' . "\n"; |
|
298 | - $add_protocol .= "\t\t\t\t" . '<li>$myKses->AddProtocol("alpha", "beta", "gamma:");</li>' . "\n"; |
|
294 | + $add_protocol .= "\t\t\t\t".'<li>$myKses->AddProtocols(array("proto1", "proto2:", "proto3"));</li>'."\n"; |
|
295 | + $add_protocol .= "\t\t\t\t".'<li>$myKses->AddProtocols("proto4:");</li>'."\n"; |
|
296 | + $add_protocol .= "\t\t\t\t".'<li>$myKses->AddProtocols("proto4:");</li>'."\n"; |
|
297 | + $add_protocol .= "\t\t\t\t".'<li>$myKses->AddProtocol("proto9", "mystery:", "anarchy");</li>'."\n"; |
|
298 | + $add_protocol .= "\t\t\t\t".'<li>$myKses->AddProtocol("alpha", "beta", "gamma:");</li>'."\n"; |
|
299 | 299 | $add_protocol .= "\t\t\t</ol>\n"; |
300 | 300 | |
301 | 301 | array_push($out_text, $add_protocol); |
302 | 302 | |
303 | 303 | $new_prots = $myKses->dumpProtocols(); |
304 | - if(count($new_prots) > 0) |
|
304 | + if (count($new_prots) > 0) |
|
305 | 305 | { |
306 | - array_push($out_text, "New protocols from KSES" . KSESTEST_VER . " after using AddProtocol(s):"); |
|
306 | + array_push($out_text, "New protocols from KSES".KSESTEST_VER." after using AddProtocol(s):"); |
|
307 | 307 | array_push($out_text, output_ul($new_prots)); |
308 | 308 | array_push($out_text, output_hr()); |
309 | 309 | } |
@@ -314,31 +314,31 @@ discard block |
||
314 | 314 | $myKses->RemoveProtocol("gamma"); |
315 | 315 | |
316 | 316 | $remove_protocol = "\t\t\t<ol>\n"; |
317 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocols(array("mystery", "anarchy:"));</li>' . "\n"; |
|
318 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocols("alpha:");</li>' . "\n"; |
|
319 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocol("beta:");</li>' . "\n"; |
|
320 | - $remove_protocol .= "\t\t\t\t" . '<li>$myKses->RemoveProtocol("gamma");</li>' . "\n"; |
|
317 | + $remove_protocol .= "\t\t\t\t".'<li>$myKses->RemoveProtocols(array("mystery", "anarchy:"));</li>'."\n"; |
|
318 | + $remove_protocol .= "\t\t\t\t".'<li>$myKses->RemoveProtocols("alpha:");</li>'."\n"; |
|
319 | + $remove_protocol .= "\t\t\t\t".'<li>$myKses->RemoveProtocol("beta:");</li>'."\n"; |
|
320 | + $remove_protocol .= "\t\t\t\t".'<li>$myKses->RemoveProtocol("gamma");</li>'."\n"; |
|
321 | 321 | $remove_protocol .= "\t\t\t</ol>\n"; |
322 | 322 | array_push($out_text, $remove_protocol); |
323 | 323 | |
324 | 324 | $new_prots = $myKses->dumpProtocols(); |
325 | - if(count($new_prots) > 0) |
|
325 | + if (count($new_prots) > 0) |
|
326 | 326 | { |
327 | - array_push($out_text, "Resulting protocols from KSES" . KSESTEST_VER . " after using RemoveProtocol(s):"); |
|
327 | + array_push($out_text, "Resulting protocols from KSES".KSESTEST_VER." after using RemoveProtocol(s):"); |
|
328 | 328 | array_push($out_text, output_ul($new_prots)); |
329 | 329 | array_push($out_text, output_hr()); |
330 | 330 | } |
331 | 331 | |
332 | 332 | $myKses->SetProtocols(array("https", "gopher", "news")); |
333 | 333 | $set_protocol = "\t\t\t<ol>\n"; |
334 | - $set_protocol .= "\t\t\t\t" . '<li>$myKses->SetProtocols(array("https", "gopher", "news"));</li>' . "\n"; |
|
334 | + $set_protocol .= "\t\t\t\t".'<li>$myKses->SetProtocols(array("https", "gopher", "news"));</li>'."\n"; |
|
335 | 335 | $set_protocol .= "\t\t\t</ol>\n"; |
336 | 336 | array_push($out_text, $set_protocol); |
337 | 337 | |
338 | 338 | $new_prots = $myKses->dumpProtocols(); |
339 | - if(count($new_prots) > 0) |
|
339 | + if (count($new_prots) > 0) |
|
340 | 340 | { |
341 | - array_push($out_text, "Resulting protocols from KSES" . KSESTEST_VER . " after using SetProtocols:"); |
|
341 | + array_push($out_text, "Resulting protocols from KSES".KSESTEST_VER." after using SetProtocols:"); |
|
342 | 342 | array_push($out_text, output_ul($new_prots)); |
343 | 343 | array_push($out_text, output_hr()); |
344 | 344 | } |
@@ -427,18 +427,18 @@ discard block |
||
427 | 427 | array_push($out, "Net results:"); |
428 | 428 | |
429 | 429 | $out_elems = $myKses->DumpElements(); |
430 | - if(count($out_elems) > 0) |
|
430 | + if (count($out_elems) > 0) |
|
431 | 431 | { |
432 | 432 | //array_push($out, "\t\t\t<ul>\n"); |
433 | - foreach($out_elems as $tag => $attr_data) |
|
433 | + foreach ($out_elems as $tag => $attr_data) |
|
434 | 434 | { |
435 | 435 | $out_li_elems = array(); |
436 | 436 | $elem_text = "(X)HTML element $tag"; |
437 | 437 | $allow = ""; |
438 | - if(isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
438 | + if (isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
439 | 439 | { |
440 | 440 | $allow = " allows attribute"; |
441 | - if(count($attr_data) > 1) |
|
441 | + if (count($attr_data) > 1) |
|
442 | 442 | { |
443 | 443 | $allow .= "s"; |
444 | 444 | } |
@@ -448,31 +448,31 @@ discard block |
||
448 | 448 | array_push($out_li_elems, "$elem_text$allow"); |
449 | 449 | |
450 | 450 | $attr_test_li = array(); |
451 | - if(isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
451 | + if (isset($attr_data) && is_array($attr_data) && count($attr_data) > 0) |
|
452 | 452 | { |
453 | - foreach($attr_data as $attr_name => $attr_tests) |
|
453 | + foreach ($attr_data as $attr_name => $attr_tests) |
|
454 | 454 | { |
455 | 455 | $li_text = $attr_name; |
456 | - if(isset($attr_tests) && count($attr_tests) > 0) |
|
456 | + if (isset($attr_tests) && count($attr_tests) > 0) |
|
457 | 457 | { |
458 | - foreach($attr_tests as $test_name => $test_val) |
|
458 | + foreach ($attr_tests as $test_name => $test_val) |
|
459 | 459 | { |
460 | - switch($test_name) |
|
460 | + switch ($test_name) |
|
461 | 461 | { |
462 | 462 | case "maxlen": |
463 | - $li_text .= " - maximum length of '" . $test_val . "' characters"; |
|
463 | + $li_text .= " - maximum length of '".$test_val."' characters"; |
|
464 | 464 | break; |
465 | 465 | case "minlen": |
466 | - $li_text .= " - minimum length of '" . $test_val . "' characters"; |
|
466 | + $li_text .= " - minimum length of '".$test_val."' characters"; |
|
467 | 467 | break; |
468 | 468 | case "minval": |
469 | - $li_text .= " - minimum value of '" . $test_val . "'"; |
|
469 | + $li_text .= " - minimum value of '".$test_val."'"; |
|
470 | 470 | break; |
471 | 471 | case "maxval": |
472 | - $li_text .= " - maximum value of '" . $test_val . "'"; |
|
472 | + $li_text .= " - maximum value of '".$test_val."'"; |
|
473 | 473 | break; |
474 | 474 | case "valueless": |
475 | - switch(strtolower($test_val)) |
|
475 | + switch (strtolower($test_val)) |
|
476 | 476 | { |
477 | 477 | case 'n': |
478 | 478 | $li_text .= " - must not be valueless"; |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | } |
492 | 492 | array_push($attr_test_li, $li_text); |
493 | 493 | } |
494 | - if(count($attr_test_li) > 0) |
|
494 | + if (count($attr_test_li) > 0) |
|
495 | 495 | { |
496 | 496 | $attr_test_li = output_ul($attr_test_li, " "); |
497 | 497 | $out_li_elems = array("$elem_text$allow$attr_test_li"); |
@@ -8,12 +8,10 @@ discard block |
||
8 | 8 | if(substr(phpversion(), 0, 1) < 4) |
9 | 9 | { |
10 | 10 | define('KSESTEST_VER', 0); |
11 | - } |
|
12 | - elseif(substr(phpversion(), 0, 1) >= 5) |
|
11 | + } elseif(substr(phpversion(), 0, 1) >= 5) |
|
13 | 12 | { |
14 | 13 | define('KSESTEST_VER', 5); |
15 | - } |
|
16 | - else |
|
14 | + } else |
|
17 | 15 | { |
18 | 16 | define('KSESTEST_VER', 4); |
19 | 17 | } |
@@ -22,8 +20,7 @@ discard block |
||
22 | 20 | if($_SERVER["DOCUMENT_ROOT"] == "") |
23 | 21 | { |
24 | 22 | define('KSESTEST_ENV', 'CLI'); |
25 | - } |
|
26 | - else |
|
23 | + } else |
|
27 | 24 | { |
28 | 25 | define('KSESTEST_ENV', 'WEB'); |
29 | 26 | } |
@@ -48,8 +45,7 @@ discard block |
||
48 | 45 | if(file_exists($include_file) && is_readable($include_file)) |
49 | 46 | { |
50 | 47 | include_once($include_file); |
51 | - } |
|
52 | - else |
|
48 | + } else |
|
53 | 49 | { |
54 | 50 | $message = array( |
55 | 51 | "Error: Unable to find '" . $include_file . "'.", |
@@ -126,8 +122,7 @@ discard block |
||
126 | 122 | if(KSESTEST_ENV == 'CLI') |
127 | 123 | { |
128 | 124 | return $text; |
129 | - } |
|
130 | - else |
|
125 | + } else |
|
131 | 126 | { |
132 | 127 | return "<code>\n$text<code>\n"; |
133 | 128 | } |
@@ -138,8 +133,7 @@ discard block |
||
138 | 133 | if(KSESTEST_ENV == 'CLI') |
139 | 134 | { |
140 | 135 | return $text; |
141 | - } |
|
142 | - else |
|
136 | + } else |
|
143 | 137 | { |
144 | 138 | return htmlentities($text); |
145 | 139 | } |
@@ -150,14 +144,12 @@ discard block |
||
150 | 144 | if(KSESTEST_ENV == 'CLI') |
151 | 145 | { |
152 | 146 | return '[' . $text . ']'; |
153 | - } |
|
154 | - else |
|
147 | + } else |
|
155 | 148 | { |
156 | 149 | if($pass == true) |
157 | 150 | { |
158 | 151 | return '<span style="color: green;">[' . $text . ']</span>'; |
159 | - } |
|
160 | - else |
|
152 | + } else |
|
161 | 153 | { |
162 | 154 | return '<span style="color: red;">[' . $text . ']</span>'; |
163 | 155 | } |
@@ -169,8 +161,7 @@ discard block |
||
169 | 161 | if(KSESTEST_ENV == 'WEB') |
170 | 162 | { |
171 | 163 | $out = " "; |
172 | - } |
|
173 | - else |
|
164 | + } else |
|
174 | 165 | { |
175 | 166 | $out = " "; |
176 | 167 | } |
@@ -183,8 +174,7 @@ discard block |
||
183 | 174 | if(KSESTEST_ENV == 'WEB') |
184 | 175 | { |
185 | 176 | $out = "<br />\n"; |
186 | - } |
|
187 | - else |
|
177 | + } else |
|
188 | 178 | { |
189 | 179 | $out = "\n"; |
190 | 180 | } |
@@ -207,8 +197,7 @@ discard block |
||
207 | 197 | $out .= "\t\t<p>\n"; |
208 | 198 | $out .= "\t\t\t$text\n"; |
209 | 199 | $out .= "\t\t</p>\n"; |
210 | - } |
|
211 | - else |
|
200 | + } else |
|
212 | 201 | { |
213 | 202 | $header = "$title\n" . str_repeat('-', 60) . "\n\n"; |
214 | 203 | $out .= "\t$text\n\n"; |
@@ -226,8 +215,7 @@ discard block |
||
226 | 215 | echo $out; |
227 | 216 | echo "\t</body>\n"; |
228 | 217 | echo "</html>\n"; |
229 | - } |
|
230 | - else |
|
218 | + } else |
|
231 | 219 | { |
232 | 220 | echo $header; |
233 | 221 | echo $out; |
@@ -239,8 +227,7 @@ discard block |
||
239 | 227 | if(KSESTEST_ENV == 'WEB') |
240 | 228 | { |
241 | 229 | return "\t\t\t<hr />\n"; |
242 | - } |
|
243 | - else |
|
230 | + } else |
|
244 | 231 | { |
245 | 232 | return str_repeat(60, '-') . "\n"; |
246 | 233 | } |
@@ -262,8 +249,7 @@ discard block |
||
262 | 249 | $text .= "\t\t\t\t<li>$li</li>\n"; |
263 | 250 | } |
264 | 251 | $text .= "\t\t\t</ul>\n"; |
265 | - } |
|
266 | - else |
|
252 | + } else |
|
267 | 253 | { |
268 | 254 | foreach($data as $li) |
269 | 255 | { |
@@ -266,6 +266,7 @@ discard block |
||
266 | 266 | * @global bool $is_platformAdmin |
267 | 267 | * @global bool $is_allowedCreateCourse |
268 | 268 | * @global object $_user |
269 | + * @param boolean $reset |
|
269 | 270 | */ |
270 | 271 | public static function init_user($user_id, $reset) |
271 | 272 | { |
@@ -355,7 +356,7 @@ discard block |
||
355 | 356 | * @global type $is_allowed_in_course |
356 | 357 | * |
357 | 358 | * @param type $course_id |
358 | - * @param type $reset |
|
359 | + * @param boolean $reset |
|
359 | 360 | */ |
360 | 361 | static function init_course($course_id, $reset) |
361 | 362 | { |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | if ($by_username) { |
38 | 38 | $secret_word = self::get_secret_word($user['email']); |
39 | 39 | if ($reset) { |
40 | - $reset_link = $portal_url . "main/auth/lostPassword.php?reset=" . $secret_word . "&id=" . $user['uid']; |
|
40 | + $reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$user['uid']; |
|
41 | 41 | } else { |
42 | - $reset_link = get_lang('Pass') . " : $user[password]"; |
|
42 | + $reset_link = get_lang('Pass')." : $user[password]"; |
|
43 | 43 | } |
44 | - $user_account_list = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $user['loginName'] . "\n" . get_lang('ResetLink') . ' : ' . $reset_link . ''; |
|
44 | + $user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.''; |
|
45 | 45 | |
46 | 46 | if ($user_account_list) { |
47 | - $user_account_list = "\n-----------------------------------------------\n" . $user_account_list; |
|
47 | + $user_account_list = "\n-----------------------------------------------\n".$user_account_list; |
|
48 | 48 | } |
49 | 49 | } else { |
50 | 50 | foreach ($user as $this_user) { |
51 | 51 | $secret_word = self::get_secret_word($this_user['email']); |
52 | 52 | if ($reset) { |
53 | - $reset_link = $portal_url . "main/auth/lostPassword.php?reset=" . $secret_word . "&id=" . $this_user['uid']; |
|
53 | + $reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$this_user['uid']; |
|
54 | 54 | } else { |
55 | - $reset_link = get_lang('Pass') . " : $this_user[password]"; |
|
55 | + $reset_link = get_lang('Pass')." : $this_user[password]"; |
|
56 | 56 | } |
57 | - $user_account_list[] = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $this_user['loginName'] . "\n" . get_lang('ResetLink') . ' : ' . $reset_link . ''; |
|
57 | + $user_account_list[] = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$this_user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.''; |
|
58 | 58 | } |
59 | 59 | if ($user_account_list) { |
60 | 60 | $user_account_list = implode("\n-----------------------------------------------\n", $user_account_list); |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | if (!$by_username) { |
65 | 65 | $user = $user[0]; |
66 | 66 | } |
67 | - $reset_link = get_lang('Pass') . " : $user[password]"; |
|
68 | - $user_account_list = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $user['loginName'] . "\n" . $reset_link . ''; |
|
67 | + $reset_link = get_lang('Pass')." : $user[password]"; |
|
68 | + $user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".$reset_link.''; |
|
69 | 69 | } |
70 | 70 | return $user_account_list; |
71 | 71 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public static function send_password_to_user($user, $by_username = false) |
80 | 80 | { |
81 | - $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT |
|
81 | + $email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT |
|
82 | 82 | |
83 | 83 | if ($by_username) { // Show only for lost password |
84 | 84 | $user_account_list = self::get_user_account_list($user, false, $by_username); // BODY |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - $email_body = get_lang('YourAccountParam') . " " . $portal_url . "\n\n$user_account_list"; |
|
100 | + $email_body = get_lang('YourAccountParam')." ".$portal_url."\n\n$user_account_list"; |
|
101 | 101 | // SEND MESSAGE |
102 | 102 | $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); |
103 | 103 | $email_admin = api_get_setting('emailAdministrator'); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public static function handle_encrypted_password($user, $by_username = false) |
133 | 133 | { |
134 | - $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT |
|
134 | + $email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT |
|
135 | 135 | |
136 | 136 | if ($by_username) { |
137 | 137 | // Show only for lost password |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | $user_account_list = self::get_user_account_list($user, true); // BODY |
142 | 142 | $email_to = $user[0]['email']; |
143 | 143 | } |
144 | - $email_body = get_lang('DearUser') . " :\n" . get_lang('password_request') . "\n"; |
|
145 | - $email_body .= $user_account_list . "\n-----------------------------------------------\n\n"; |
|
144 | + $email_body = get_lang('DearUser')." :\n".get_lang('password_request')."\n"; |
|
145 | + $email_body .= $user_account_list."\n-----------------------------------------------\n\n"; |
|
146 | 146 | $email_body .= get_lang('PasswordEncryptedForSecurity'); |
147 | 147 | |
148 | - $email_body .= "\n\n" . get_lang('SignatureFormula') . ",\n" . api_get_setting('administratorName') . " " . api_get_setting('administratorSurname') . "\n" . get_lang('PlataformAdmin') . " - " . api_get_setting('siteName'); |
|
148 | + $email_body .= "\n\n".get_lang('SignatureFormula').",\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n".get_lang('PlataformAdmin')." - ".api_get_setting('siteName'); |
|
149 | 149 | |
150 | 150 | $sender_name = api_get_person_name( |
151 | 151 | api_get_setting('administratorName'), |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | username AS loginName, |
239 | 239 | password, |
240 | 240 | |
241 | - FROM " . $tbl_user . " |
|
241 | + FROM " . $tbl_user." |
|
242 | 242 | WHERE user_id = $id"; |
243 | 243 | $result = Database::query($sql); |
244 | 244 | $num_rows = Database::num_rows($result); |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ON user.user_id = a.user_id |
292 | 292 | LEFT JOIN $track_e_login login |
293 | 293 | ON user.user_id = login.login_user_id |
294 | - WHERE user.user_id = '" . $_user['user_id'] . "' |
|
294 | + WHERE user.user_id = '".$_user['user_id']."' |
|
295 | 295 | ORDER BY login.login_date DESC LIMIT 1"; |
296 | 296 | |
297 | 297 | $result = Database::query($sql); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | Session::write('is_platformAdmin', $is_platformAdmin); |
322 | 322 | Session::write('is_allowedCreateCourse', $is_allowedCreateCourse); |
323 | 323 | } else { |
324 | - header('location:' . api_get_path(WEB_PATH)); |
|
324 | + header('location:'.api_get_path(WEB_PATH)); |
|
325 | 325 | //exit("WARNING UNDEFINED UID !! "); |
326 | 326 | } |
327 | 327 | } else { // no uid => logout or Anonymous |
@@ -368,9 +368,9 @@ discard block |
||
368 | 368 | global $_course; |
369 | 369 | global $_real_cid; |
370 | 370 | |
371 | - global $is_courseAdmin; //course teacher |
|
372 | - global $is_courseTutor; //course teacher - some rights |
|
373 | - global $is_courseCoach; //course coach |
|
371 | + global $is_courseAdmin; //course teacher |
|
372 | + global $is_courseTutor; //course teacher - some rights |
|
373 | + global $is_courseCoach; //course coach |
|
374 | 374 | global $is_courseMember; //course student |
375 | 375 | global $is_sessionAdmin; |
376 | 376 | global $is_allowed_in_course; |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | |
428 | 428 | if (!empty($_GET['id_session'])) { |
429 | 429 | $_SESSION['id_session'] = intval($_GET['id_session']); |
430 | - $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"'; |
|
430 | + $sql = 'SELECT name FROM '.$tbl_session.' WHERE id="'.intval($_SESSION['id_session']).'"'; |
|
431 | 431 | $rs = Database::query($sql); |
432 | 432 | list($_SESSION['session_name']) = Database::fetch_array($rs); |
433 | 433 | } else { |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | } |
444 | 444 | } else { |
445 | 445 | //exit("WARNING UNDEFINED CID !! "); |
446 | - header('location:' . api_get_path(WEB_PATH)); |
|
446 | + header('location:'.api_get_path(WEB_PATH)); |
|
447 | 447 | } |
448 | 448 | } else { |
449 | 449 | Session::erase('_cid'); |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | } else { |
471 | 471 | // Continue with the previous values |
472 | 472 | if (empty($_SESSION['_course']) OR empty($_SESSION['_cid'])) { //no previous values... |
473 | - $_cid = -1; //set default values that will be caracteristic of being unset |
|
473 | + $_cid = -1; //set default values that will be caracteristic of being unset |
|
474 | 474 | $_course = -1; |
475 | 475 | } else { |
476 | 476 | $_cid = $_SESSION['_cid']; |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | // Moreover, if we want to track a course with another session it can be usefull |
481 | 481 | if (!empty($_GET['id_session'])) { |
482 | 482 | $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
483 | - $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"'; |
|
483 | + $sql = 'SELECT name FROM '.$tbl_session.' WHERE id="'.intval($_SESSION['id_session']).'"'; |
|
484 | 484 | $rs = Database::query($sql); |
485 | 485 | list($_SESSION['session_name']) = Database::fetch_array($rs); |
486 | 486 | $_SESSION['id_session'] = intval($_GET['id_session']); |
@@ -520,9 +520,9 @@ discard block |
||
520 | 520 | //But only if the login date is < than now + max_life_time |
521 | 521 | $sql = "SELECT course_access_id FROM $course_tracking_table |
522 | 522 | WHERE |
523 | - user_id = " . intval($_user ['user_id']) . " AND |
|
523 | + user_id = ".intval($_user ['user_id'])." AND |
|
524 | 524 | c_id = '".api_get_course_int_id()."' AND |
525 | - session_id = " . api_get_session_id() . " AND |
|
525 | + session_id = " . api_get_session_id()." AND |
|
526 | 526 | login_course_date > now() - INTERVAL $session_lifetime SECOND |
527 | 527 | ORDER BY login_course_date DESC LIMIT 0,1"; |
528 | 528 | $result = Database::query($sql); |
@@ -532,11 +532,11 @@ discard block |
||
532 | 532 | //We update the course tracking table |
533 | 533 | $sql = "UPDATE $course_tracking_table |
534 | 534 | SET logout_course_date = '$time', counter = counter+1 |
535 | - WHERE course_access_id = " . intval($i_course_access_id) . " AND session_id = " . api_get_session_id(); |
|
535 | + WHERE course_access_id = ".intval($i_course_access_id)." AND session_id = ".api_get_session_id(); |
|
536 | 536 | Database::query($sql); |
537 | 537 | } else { |
538 | - $sql = "INSERT INTO $course_tracking_table (c_id, user_id, login_course_date, logout_course_date, counter, session_id)" . |
|
539 | - "VALUES('" . api_get_course_int_id() . "', '" . $_user['user_id'] . "', '$time', '$time', '1','" . api_get_session_id() . "')"; |
|
538 | + $sql = "INSERT INTO $course_tracking_table (c_id, user_id, login_course_date, logout_course_date, counter, session_id)". |
|
539 | + "VALUES('".api_get_course_int_id()."', '".$_user['user_id']."', '$time', '$time', '1','".api_get_session_id()."')"; |
|
540 | 540 | Database::query($sql); |
541 | 541 | } |
542 | 542 | } |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
565 | 565 | $sql = "SELECT * FROM $course_user_table |
566 | 566 | WHERE |
567 | - user_id = '" . $user_id . "' AND |
|
568 | - relation_type <> " . COURSE_RELATION_TYPE_RRHH . " AND |
|
567 | + user_id = '".$user_id."' AND |
|
568 | + relation_type <> " . COURSE_RELATION_TYPE_RRHH." AND |
|
569 | 569 | course_code = '$course_id'"; |
570 | 570 | $result = Database::query($sql); |
571 | 571 | |
@@ -585,8 +585,8 @@ discard block |
||
585 | 585 | $session_id |
586 | 586 | ); |
587 | 587 | if (!$user_is_subscribed) { |
588 | - $url = api_get_path(WEB_CODE_PATH) . 'course_info/legal.php?course_code=' . $_course['code'] . '&session_id=' . $session_id; |
|
589 | - header('Location: ' . $url); |
|
588 | + $url = api_get_path(WEB_CODE_PATH).'course_info/legal.php?course_code='.$_course['code'].'&session_id='.$session_id; |
|
589 | + header('Location: '.$url); |
|
590 | 590 | exit; |
591 | 591 | } |
592 | 592 | } |
@@ -627,11 +627,11 @@ discard block |
||
627 | 627 | } else { |
628 | 628 | //Im a coach or a student? |
629 | 629 | $sql = "SELECT user_id, status |
630 | - FROM " . $tbl_session_course_user . " |
|
630 | + FROM " . $tbl_session_course_user." |
|
631 | 631 | WHERE |
632 | 632 | c_id = '$_cid' AND |
633 | - user_id = '" . $user_id . "' AND |
|
634 | - session_id = '" . $session_id . "' |
|
633 | + user_id = '".$user_id."' AND |
|
634 | + session_id = '" . $session_id."' |
|
635 | 635 | LIMIT 1"; |
636 | 636 | $result = Database::query($sql); |
637 | 637 | |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | if ($reset) { // session data refresh requested |
778 | 778 | if ($group_id && $_cid && !empty($_course['real_id'])) { // have keys to search data |
779 | 779 | $group_table = Database::get_course_table(TABLE_GROUP); |
780 | - $sql = "SELECT * FROM $group_table WHERE c_id = " . $_course['real_id'] . " AND id = '$group_id'"; |
|
780 | + $sql = "SELECT * FROM $group_table WHERE c_id = ".$_course['real_id']." AND id = '$group_id'"; |
|
781 | 781 | $result = Database::query($sql); |
782 | 782 | if (Database::num_rows($result) > 0) { // This group has recorded status related to this course |
783 | 783 | $gpData = Database::fetch_array($result); |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | */ |
831 | 831 | public static function get_user_accounts_by_username($username) |
832 | 832 | { |
833 | - if (strpos($username,'@')){ |
|
833 | + if (strpos($username, '@')) { |
|
834 | 834 | $username = api_strtolower($username); |
835 | 835 | $email = true; |
836 | 836 | } else { |
@@ -852,14 +852,14 @@ discard block |
||
852 | 852 | $email = false; |
853 | 853 | } |
854 | 854 | |
855 | - if ($email) { |
|
856 | - $condition = "LOWER(email) = '".Database::escape_string($username)."' "; |
|
857 | - } else { |
|
855 | + if ($email) { |
|
856 | + $condition = "LOWER(email) = '".Database::escape_string($username)."' "; |
|
857 | + } else { |
|
858 | 858 | $condition = "LOWER(username) = '".Database::escape_string($username)."'"; |
859 | 859 | } |
860 | 860 | |
861 | - $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
862 | - $query = "SELECT |
|
861 | + $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
862 | + $query = "SELECT |
|
863 | 863 | user_id AS uid, |
864 | 864 | lastname AS lastName, |
865 | 865 | firstname AS firstName, |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | auth_source |
875 | 875 | FROM $tbl_user |
876 | 876 | WHERE ( $condition AND active = 1) "; |
877 | - $result = Database::query($query); |
|
877 | + $result = Database::query($query); |
|
878 | 878 | $num_rows = Database::num_rows($result); |
879 | 879 | if ($result && $num_rows > 0) { |
880 | 880 | return Database::fetch_assoc($result); |
@@ -616,6 +616,8 @@ discard block |
||
616 | 616 | * @param int message id |
617 | 617 | * @param int message user id (receiver user id or sender user id) |
618 | 618 | * @param int group id (optional) |
619 | + * @param integer $message_id |
|
620 | + * @param integer $message_uid |
|
619 | 621 | * @return void |
620 | 622 | */ |
621 | 623 | public static function delete_message_attachment_file($message_id, $message_uid, $group_id = 0) |
@@ -660,7 +662,7 @@ discard block |
||
660 | 662 | * update messages by user id and message id |
661 | 663 | * @param int $user_id |
662 | 664 | * @param int $message_id |
663 | - * @return resource |
|
665 | + * @return false|null |
|
664 | 666 | */ |
665 | 667 | public static function update_message($user_id, $message_id) |
666 | 668 | { |
@@ -680,7 +682,7 @@ discard block |
||
680 | 682 | * @param int $user_id |
681 | 683 | * @param int $message_id |
682 | 684 | * @param string $type |
683 | - * @return bool |
|
685 | + * @return false|null |
|
684 | 686 | */ |
685 | 687 | public static function update_message_status($user_id, $message_id,$type) |
686 | 688 | { |
@@ -717,6 +719,7 @@ discard block |
||
717 | 719 | /** |
718 | 720 | * get messages by group id |
719 | 721 | * @param int group id |
722 | + * @param integer $group_id |
|
720 | 723 | * @return array |
721 | 724 | */ |
722 | 725 | public static function get_messages_by_group($group_id) |
@@ -1433,7 +1436,7 @@ discard block |
||
1433 | 1436 | * Sort date by desc from a multi-dimensional array |
1434 | 1437 | * @param array $array1 first array to compare |
1435 | 1438 | * @param array $array2 second array to compare |
1436 | - * @return bool |
|
1439 | + * @return integer |
|
1437 | 1440 | */ |
1438 | 1441 | public function order_desc_date($array1, $array2) |
1439 | 1442 | { |
@@ -1511,7 +1514,6 @@ discard block |
||
1511 | 1514 | /** |
1512 | 1515 | * @param $id |
1513 | 1516 | * @param array $params |
1514 | - * @param string $display |
|
1515 | 1517 | * @return string |
1516 | 1518 | */ |
1517 | 1519 | public static function generate_invitation_form($id, $params = array()) |
@@ -1532,7 +1532,7 @@ |
||
1532 | 1532 | |
1533 | 1533 | if (isset($_REQUEST['action'])) { |
1534 | 1534 | switch ($_REQUEST['action']) { |
1535 | - case 'mark_as_unread' : |
|
1535 | + case 'mark_as_unread' : |
|
1536 | 1536 | $number_of_selected_messages = count($_POST['id']); |
1537 | 1537 | if (is_array($_POST['id'])) { |
1538 | 1538 | foreach ($_POST['id'] as $index => $message_id) { |
@@ -131,8 +131,9 @@ discard block |
||
131 | 131 | $direction = 'DESC'; |
132 | 132 | } else { |
133 | 133 | $column = intval($column); |
134 | - if (!in_array($direction, array('ASC', 'DESC'))) |
|
135 | - $direction = 'ASC'; |
|
134 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
135 | + $direction = 'ASC'; |
|
136 | + } |
|
136 | 137 | } |
137 | 138 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
138 | 139 | |
@@ -488,8 +489,9 @@ discard block |
||
488 | 489 | public static function delete_message_by_user_receiver($user_receiver_id, $id) |
489 | 490 | { |
490 | 491 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
491 | - if ($id != strval(intval($id))) |
|
492 | - return false; |
|
492 | + if ($id != strval(intval($id))) { |
|
493 | + return false; |
|
494 | + } |
|
493 | 495 | $user_receiver_id = intval($user_receiver_id); |
494 | 496 | $id = intval($id); |
495 | 497 | $sql = "SELECT * FROM $table_message |
@@ -664,8 +666,9 @@ discard block |
||
664 | 666 | */ |
665 | 667 | public static function update_message($user_id, $message_id) |
666 | 668 | { |
667 | - if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id))) |
|
668 | - return false; |
|
669 | + if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id))) { |
|
670 | + return false; |
|
671 | + } |
|
669 | 672 | |
670 | 673 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
671 | 674 | $sql = "UPDATE $table_message SET msg_status = '0' |
@@ -705,8 +708,9 @@ discard block |
||
705 | 708 | */ |
706 | 709 | public static function get_message_by_user($user_id, $message_id) |
707 | 710 | { |
708 | - if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id))) |
|
709 | - return false; |
|
711 | + if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id))) { |
|
712 | + return false; |
|
713 | + } |
|
710 | 714 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
711 | 715 | $query = "SELECT * FROM $table_message |
712 | 716 | WHERE user_receiver_id=".intval($user_id)." AND id='".intval($message_id)."'"; |
@@ -721,8 +725,9 @@ discard block |
||
721 | 725 | */ |
722 | 726 | public static function get_messages_by_group($group_id) |
723 | 727 | { |
724 | - if ($group_id != strval(intval($group_id))) |
|
725 | - return false; |
|
728 | + if ($group_id != strval(intval($group_id))) { |
|
729 | + return false; |
|
730 | + } |
|
726 | 731 | |
727 | 732 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
728 | 733 | $group_id = intval($group_id); |
@@ -749,8 +754,9 @@ discard block |
||
749 | 754 | */ |
750 | 755 | public static function get_messages_by_group_by_message($group_id, $message_id) |
751 | 756 | { |
752 | - if ($group_id != strval(intval($group_id))) |
|
753 | - return false; |
|
757 | + if ($group_id != strval(intval($group_id))) { |
|
758 | + return false; |
|
759 | + } |
|
754 | 760 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
755 | 761 | $group_id = intval($group_id); |
756 | 762 | $sql = "SELECT * FROM $table_message |
@@ -828,8 +834,9 @@ discard block |
||
828 | 834 | */ |
829 | 835 | public static function exist_message($user_id, $id) |
830 | 836 | { |
831 | - if ($id != strval(intval($id)) || $user_id != strval(intval($user_id))) |
|
832 | - return false; |
|
837 | + if ($id != strval(intval($id)) || $user_id != strval(intval($user_id))) { |
|
838 | + return false; |
|
839 | + } |
|
833 | 840 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
834 | 841 | $query = "SELECT id FROM $table_message |
835 | 842 | WHERE |
@@ -860,8 +867,9 @@ discard block |
||
860 | 867 | $direction = 'DESC'; |
861 | 868 | } else { |
862 | 869 | $column = intval($column); |
863 | - if (!in_array($direction, array('ASC', 'DESC'))) |
|
864 | - $direction = 'ASC'; |
|
870 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
871 | + $direction = 'ASC'; |
|
872 | + } |
|
865 | 873 | } |
866 | 874 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
867 | 875 | $request = api_is_xml_http_request(); |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | * @param string $type |
714 | 714 | * @return bool |
715 | 715 | */ |
716 | - public static function update_message_status($user_id, $message_id,$type) |
|
716 | + public static function update_message_status($user_id, $message_id, $type) |
|
717 | 717 | { |
718 | 718 | $type = intval($type); |
719 | 719 | if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id))) { |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | |
1049 | 1049 | $receiverUserInfo = api_get_user_info($row['user_receiver_id']); |
1050 | 1050 | |
1051 | - $message_content .='<tr>'; |
|
1051 | + $message_content .= '<tr>'; |
|
1052 | 1052 | if (api_get_setting('allow_social_tool') == 'true') { |
1053 | 1053 | if ($source == 'outbox') { |
1054 | 1054 | $message_content .= get_lang('From').': <a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_sender_id.'">'.$name.'</a> '. |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | $message_content .= get_lang('From').': '.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.get_lang('Me').'</b>'; |
1065 | 1065 | } |
1066 | 1066 | } |
1067 | - $message_content .=' '.get_lang('Date').': '.api_get_local_time($row['send_date']).' |
|
1067 | + $message_content .= ' '.get_lang('Date').': '.api_get_local_time($row['send_date']).' |
|
1068 | 1068 | <br /> |
1069 | 1069 | <hr style="color:#ddd" /> |
1070 | 1070 | <table height="209px" width="100%"> |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | $message_content .= '<a href="inbox.php?action=deleteone&id='.$message_id.'&'.$social_link.'" >'. |
1091 | 1091 | Display::return_icon('delete.png', get_lang('DeleteMessage')).'</a> '; |
1092 | 1092 | |
1093 | - $message_content .='</div></td> |
|
1093 | + $message_content .= '</div></td> |
|
1094 | 1094 | <td width=10></td> |
1095 | 1095 | </tr> |
1096 | 1096 | </table>'; |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | $items = $topic['count']; |
1169 | 1169 | $reply_label = ($items == 1) ? get_lang('GroupReply') : get_lang('GroupReplies'); |
1170 | - $label = Display::label($items.' '.$reply_label); |
|
1170 | + $label = Display::label($items.' '.$reply_label); |
|
1171 | 1171 | $topic['title'] = trim($topic['title']); |
1172 | 1172 | |
1173 | 1173 | if (empty($topic['title'])) { |
@@ -1277,7 +1277,7 @@ discard block |
||
1277 | 1277 | $name = $user_sender_info['complete_name']; |
1278 | 1278 | |
1279 | 1279 | $topic_page_nr = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : null; |
1280 | - $links.= '<div id="message-reply-link">'; |
|
1280 | + $links .= '<div id="message-reply-link">'; |
|
1281 | 1281 | if (($my_group_role == GROUP_USER_PERMISSION_ADMIN || |
1282 | 1282 | $my_group_role == GROUP_USER_PERMISSION_MODERATOR) || |
1283 | 1283 | $main_message['user_sender_id'] == $current_user_id |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | 'group_id' => $group_id, |
1290 | 1290 | 'message_id' => $main_message['id'], |
1291 | 1291 | 'action' => 'edit_message_group', |
1292 | - 'anchor_topic' => 'topic_' . $main_message['id'], |
|
1292 | + 'anchor_topic' => 'topic_'.$main_message['id'], |
|
1293 | 1293 | 'topics_page_nr' => $topic_page_nr, |
1294 | 1294 | 'items_page_nr' => $items_page_nr, |
1295 | 1295 | 'topic_id' => $main_message['id'] |
@@ -1319,7 +1319,7 @@ discard block |
||
1319 | 1319 | 'group_id' => $group_id, |
1320 | 1320 | 'message_id' => $main_message['id'], |
1321 | 1321 | 'action' => 'reply_message_group', |
1322 | - 'anchor_topic' => 'topic_' . $main_message['id'], |
|
1322 | + 'anchor_topic' => 'topic_'.$main_message['id'], |
|
1323 | 1323 | 'topics_page_nr' => $topic_page_nr, |
1324 | 1324 | 'topic_id' => $main_message['id'] |
1325 | 1325 | ]); |
@@ -1335,10 +1335,10 @@ discard block |
||
1335 | 1335 | ] |
1336 | 1336 | ); |
1337 | 1337 | |
1338 | - $links.= '</div>'; |
|
1338 | + $links .= '</div>'; |
|
1339 | 1339 | |
1340 | 1340 | $userPicture = $user_sender_info['avatar']; |
1341 | - $main_content.= '<div class="message-group-author"> |
|
1341 | + $main_content .= '<div class="message-group-author"> |
|
1342 | 1342 | <img src="'.$userPicture.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>'; |
1343 | 1343 | $user_link = '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$main_message['user_sender_id'].'">'.$name.' </a>'; |
1344 | 1344 | |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | $date = '<div class="message-group-date"> '.get_lang('Created').' '.date_to_str_ago($main_message['send_date']).'</div>'; |
1352 | 1352 | } |
1353 | 1353 | $attachment = '<div class="message-attach">'.(!empty($files_attachments) ? implode('<br />', $files_attachments) : '').'</div>'; |
1354 | - $main_content.= '<div class="message-group-content">'.$links.$user_link.' '.$date.$main_message['content'].$attachment.'</div>'; |
|
1354 | + $main_content .= '<div class="message-group-content">'.$links.$user_link.' '.$date.$main_message['content'].$attachment.'</div>'; |
|
1355 | 1355 | $main_content = Security::remove_XSS($main_content, STUDENT, true); |
1356 | 1356 | |
1357 | 1357 | $html .= Display::div(Display::div(Display::div($main_content, array('class' => 'group_social_sub_item', 'style' => 'background-color:#fff;')), array('class' => 'group_social_item')), array('class' => 'group_social_grid')); |
@@ -1372,18 +1372,18 @@ discard block |
||
1372 | 1372 | $files_attachments = self::get_links_message_attachment_files($topic['id']); |
1373 | 1373 | $name = $user_sender_info['complete_name']; |
1374 | 1374 | |
1375 | - $links.= '<div id="message-reply-link">'; |
|
1375 | + $links .= '<div id="message-reply-link">'; |
|
1376 | 1376 | if (($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) || $topic['user_sender_id'] == $current_user_id) { |
1377 | - $links.= '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?height=400&width=800&&user_friend='.$current_user_id.'&group_id='.$group_id.'&message_id='.$topic['id'].'&action=edit_message_group&anchor_topic=topic_'.$topic_id.'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$topic_id.'" class="ajax btn" data-size="lg" data-title="'.get_lang('Edit').'" title="'.get_lang('Edit').'">'. |
|
1377 | + $links .= '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?height=400&width=800&&user_friend='.$current_user_id.'&group_id='.$group_id.'&message_id='.$topic['id'].'&action=edit_message_group&anchor_topic=topic_'.$topic_id.'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$topic_id.'" class="ajax btn" data-size="lg" data-title="'.get_lang('Edit').'" title="'.get_lang('Edit').'">'. |
|
1378 | 1378 | Display :: return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>'; |
1379 | 1379 | } |
1380 | - $links.= ' <a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?height=400&width=800&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&message_id='.$topic['id'].'&action=reply_message_group&anchor_topic=topic_'.$topic_id.'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$topic_id.'" class="ajax btn" data-size="lg" data-title="'.get_lang('Reply').'" title="'.get_lang('Reply').'">'; |
|
1381 | - $links.= Display :: return_icon('talk.png', get_lang('Reply')).'</a>'; |
|
1382 | - $links.= '</div>'; |
|
1380 | + $links .= ' <a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?height=400&width=800&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&message_id='.$topic['id'].'&action=reply_message_group&anchor_topic=topic_'.$topic_id.'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$topic_id.'" class="ajax btn" data-size="lg" data-title="'.get_lang('Reply').'" title="'.get_lang('Reply').'">'; |
|
1381 | + $links .= Display :: return_icon('talk.png', get_lang('Reply')).'</a>'; |
|
1382 | + $links .= '</div>'; |
|
1383 | 1383 | |
1384 | 1384 | $userPicture = $user_sender_info['avatar']; |
1385 | 1385 | |
1386 | - $html_items.= '<div class="message-group-author"><img src="'.$userPicture.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>'; |
|
1386 | + $html_items .= '<div class="message-group-author"><img src="'.$userPicture.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>'; |
|
1387 | 1387 | $user_link = '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$topic['user_sender_id'].'">'.$name.' </a>'; |
1388 | 1388 | |
1389 | 1389 | $date = ''; |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | $date = '<div class="message-group-date"> '.get_lang('Created').' '.date_to_str_ago($topic['send_date']).'</div>'; |
1396 | 1396 | } |
1397 | 1397 | $attachment = '<div class="message-attach">'.(!empty($files_attachments) ? implode('<br />', $files_attachments) : '').'</div>'; |
1398 | - $html_items.= '<div class="message-group-content">'.$links.$user_link.' '.$date.Security::remove_XSS($topic['content'], STUDENT, true).$attachment.'</div>'; |
|
1398 | + $html_items .= '<div class="message-group-content">'.$links.$user_link.' '.$date.Security::remove_XSS($topic['content'], STUDENT, true).$attachment.'</div>'; |
|
1399 | 1399 | |
1400 | 1400 | $base_padding = 20; |
1401 | 1401 | |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | break; |
1680 | 1680 | case 'deleteone' : |
1681 | 1681 | MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']); |
1682 | - $html .=Display::return_message(api_xml_http_response_encode($success), 'normal', false); |
|
1682 | + $html .= Display::return_message(api_xml_http_response_encode($success), 'normal', false); |
|
1683 | 1683 | $html .= '<br/>'; |
1684 | 1684 | break; |
1685 | 1685 | } |
@@ -1773,7 +1773,7 @@ discard block |
||
1773 | 1773 | ON m.user_sender_id = u.user_id |
1774 | 1774 | WHERE |
1775 | 1775 | m.user_receiver_id = $userId AND |
1776 | - m.msg_status = " . MESSAGE_STATUS_UNREAD . " |
|
1776 | + m.msg_status = ".MESSAGE_STATUS_UNREAD." |
|
1777 | 1777 | AND m.id > $lastId |
1778 | 1778 | ORDER BY m.send_date DESC"; |
1779 | 1779 | |
@@ -1844,11 +1844,11 @@ discard block |
||
1844 | 1844 | $tplMailBody = new Template(null, false, false, false, false, false, false); |
1845 | 1845 | $tplMailBody->assign('user', $user); |
1846 | 1846 | $tplMailBody->assign('is_western_name_order', api_is_western_name_order()); |
1847 | - $tplMailBody->assign('manageUrl', api_get_path(WEB_CODE_PATH) . 'admin/user_edit.php?user_id=' . $user->getId()); |
|
1847 | + $tplMailBody->assign('manageUrl', api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user->getId()); |
|
1848 | 1848 | |
1849 | 1849 | $layoutContent = $tplMailBody->get_template('mail/new_user_mail_to_admin.tpl'); |
1850 | 1850 | |
1851 | - $emailsubject = '[' . get_lang('UserRegistered') . '] ' . $user->getUsername(); |
|
1851 | + $emailsubject = '['.get_lang('UserRegistered').'] '.$user->getUsername(); |
|
1852 | 1852 | $emailbody = $tplMailBody->fetch($layoutContent); |
1853 | 1853 | |
1854 | 1854 | $admins = UserManager::get_all_administrators(); |
@@ -25,6 +25,7 @@ |
||
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Useful finder - experimental akelos like only use in notification.lib.php send function |
28 | + * @param string $type |
|
28 | 29 | */ |
29 | 30 | public function find($type, $options = null) |
30 | 31 | { |
@@ -634,7 +634,6 @@ discard block |
||
634 | 634 | * @param int $sessionId The session ID |
635 | 635 | * @param int $courseId The course ID |
636 | 636 | * @param int $exerciseId The quiz ID |
637 | - * @param int $answer Answer status (0 = incorrect, 1 = correct, 2 = both) |
|
638 | 637 | * @return string HTML array of results formatted for gridJS |
639 | 638 | * @author César Perales <[email protected]>, Beeznest Team |
640 | 639 | */ |
@@ -1222,6 +1221,7 @@ discard block |
||
1222 | 1221 | * @param int Number of items to select |
1223 | 1222 | * @param string Column to order on |
1224 | 1223 | * @param string Order direction |
1224 | + * @param integer $number_of_items |
|
1225 | 1225 | * @return array Results |
1226 | 1226 | */ |
1227 | 1227 | public static function get_course_data_tracking_overview($from, $number_of_items, $column, $direction) |
@@ -1556,6 +1556,7 @@ discard block |
||
1556 | 1556 | * @param int Number of items to select |
1557 | 1557 | * @param string Column to order on |
1558 | 1558 | * @param string Order direction |
1559 | + * @param integer $number_of_items |
|
1559 | 1560 | * @return array Results |
1560 | 1561 | */ |
1561 | 1562 | public static function get_session_data_tracking_overview($from, $number_of_items, $column, $direction) |
@@ -1576,7 +1577,6 @@ discard block |
||
1576 | 1577 | /** |
1577 | 1578 | * Fills in session reporting data |
1578 | 1579 | * |
1579 | - * @param integer $user_id the id of the user |
|
1580 | 1580 | * @param array $url_params additonal url parameters |
1581 | 1581 | * @param array $row the row information (the other columns) |
1582 | 1582 | * @return string html code |
@@ -2206,6 +2206,7 @@ discard block |
||
2206 | 2206 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
2207 | 2207 | * @version Dokeos 1.8.6 |
2208 | 2208 | * @since October 2008 |
2209 | + * @param integer $number_of_items |
|
2209 | 2210 | */ |
2210 | 2211 | public static function get_user_data_tracking_overview($from, $number_of_items, $column, $direction) |
2211 | 2212 | { |
@@ -2308,7 +2309,6 @@ discard block |
||
2308 | 2309 | /** |
2309 | 2310 | * Checks if there are repeted users in a given array |
2310 | 2311 | * @param array $usernames list of the usernames in the uploaded file |
2311 | - * @param array $user_array['username'] and $user_array['sufix'] where sufix is the number part in a login i.e -> jmontoya2 |
|
2312 | 2312 | * @return array with the $usernames array and the $user_array array |
2313 | 2313 | * @author Julio Montoya Armas |
2314 | 2314 | */ |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | array('url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=course', 'content' => get_lang('DisplayCourseOverview')), |
26 | 26 | array('url' => api_get_path(WEB_CODE_PATH).'tracking/question_course_report.php?view=admin', 'content' => get_lang('LPQuestionListResults')), |
27 | 27 | array('url' => api_get_path(WEB_CODE_PATH).'tracking/course_session_report.php?view=admin', 'content' => get_lang('LPExerciseResultsBySession')), |
28 | - ['url' => api_get_path(WEB_CODE_PATH) . 'mySpace/admin_view.php?display=accessoverview', 'content' => get_lang('DisplayAccessOverview') . ' (' . get_lang('Beta') . ')'] |
|
28 | + ['url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=accessoverview', 'content' => get_lang('DisplayAccessOverview').' ('.get_lang('Beta').')'] |
|
29 | 29 | ); |
30 | 30 | |
31 | 31 | return Display :: actions($actions, null); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public static function getTopMenu() |
35 | 35 | { |
36 | 36 | $menu_items = array(); |
37 | - $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ); |
|
37 | + $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH)."auth/my_progress.php"); |
|
38 | 38 | $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher'); |
39 | 39 | $menu_items[] = Display::url(Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32), '#'); |
40 | 40 | $menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php'); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $session_id = intval($session_id); |
105 | 105 | |
106 | 106 | $sql = 'SELECT login_course_date, logout_course_date |
107 | - FROM ' . $tbl_track_course . ' |
|
107 | + FROM ' . $tbl_track_course.' |
|
108 | 108 | WHERE |
109 | 109 | user_id = '.$user_id.' AND |
110 | 110 | c_id = '.$courseId.' AND |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | foreach ($course_list as $course_item) { |
144 | 144 | $courseInfo = api_get_course_info($course_item['code']); |
145 | 145 | $courseId = $courseInfo['real_id']; |
146 | - $new_course_list[] = '"'.$courseId.'"'; |
|
146 | + $new_course_list[] = '"'.$courseId.'"'; |
|
147 | 147 | } |
148 | 148 | $course_list = implode(', ', $new_course_list); |
149 | 149 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | $sql = 'SELECT login_course_date, logout_course_date, c_id |
154 | - FROM ' . $tbl_track_course . ' |
|
154 | + FROM ' . $tbl_track_course.' |
|
155 | 155 | WHERE |
156 | 156 | user_id = '.$user_id.' AND |
157 | 157 | c_id IN ('.$course_list.') AND |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | // student score |
230 | 230 | $avg_score = Tracking :: get_avg_student_score($user_id, $courseCode); |
231 | 231 | if (is_numeric($avg_score)) { |
232 | - $avg_score = round($avg_score,2); |
|
232 | + $avg_score = round($avg_score, 2); |
|
233 | 233 | } else { |
234 | 234 | $$avg_score = '-'; |
235 | 235 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | |
266 | 266 | $t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">'; |
267 | 267 | //$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>'; |
268 | - $t_head .= '<tr>'; |
|
268 | + $t_head .= '<tr>'; |
|
269 | 269 | $t_head .= ' <th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>'; |
270 | 270 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>'; |
271 | 271 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>'; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | $addparams = array('view' => 'admin', 'display' => 'user'); |
285 | 285 | |
286 | - $table = new SortableTable('tracking_user_overview', array('MySpace','get_number_of_users_tracking_overview'), array('MySpace','get_user_data_tracking_overview'), 0); |
|
286 | + $table = new SortableTable('tracking_user_overview', array('MySpace', 'get_number_of_users_tracking_overview'), array('MySpace', 'get_user_data_tracking_overview'), 0); |
|
287 | 287 | $table->additional_parameters = $addparams; |
288 | 288 | |
289 | 289 | $table->set_header(0, get_lang('OfficialCode'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt')); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | } |
297 | 297 | $table->set_header(3, get_lang('LoginName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt')); |
298 | 298 | $table->set_header(4, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;')); |
299 | - $table->set_column_filter(4, array('MySpace','course_info_tracking_filter')); |
|
299 | + $table->set_column_filter(4, array('MySpace', 'course_info_tracking_filter')); |
|
300 | 300 | $table->display(); |
301 | 301 | } |
302 | 302 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | $table -> set_header(7, get_lang('Sessions'), false); |
342 | 342 | |
343 | 343 | if ($is_western_name_order) { |
344 | - $csv_header[] = array ( |
|
344 | + $csv_header[] = array( |
|
345 | 345 | get_lang('FirstName', ''), |
346 | 346 | get_lang('LastName', ''), |
347 | 347 | get_lang('TimeSpentOnThePlatform', ''), |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | get_lang('NumberOfSessions', '') |
352 | 352 | ); |
353 | 353 | } else { |
354 | - $csv_header[] = array ( |
|
354 | + $csv_header[] = array( |
|
355 | 355 | get_lang('LastName', ''), |
356 | 356 | get_lang('FirstName', ''), |
357 | 357 | get_lang('TimeSpentOnThePlatform', ''), |
@@ -491,9 +491,9 @@ discard block |
||
491 | 491 | |
492 | 492 | if ($tracking_column != 3) { |
493 | 493 | if ($tracking_direction == 'DESC') { |
494 | - usort($all_datas, array('MySpace','rsort_users')); |
|
494 | + usort($all_datas, array('MySpace', 'rsort_users')); |
|
495 | 495 | } else { |
496 | - usort($all_datas, array('MySpace','sort_users')); |
|
496 | + usort($all_datas, array('MySpace', 'sort_users')); |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | /** |
553 | 553 | * Column config |
554 | 554 | */ |
555 | - $column_model = array( |
|
555 | + $column_model = array( |
|
556 | 556 | array( |
557 | 557 | 'name' => 'username', |
558 | 558 | 'index' => 'username', |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | |
594 | 594 | $action_links = ''; |
595 | 595 | // jqgrid will use this URL to do the selects |
596 | - $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_lp_progress&session_id=' . $sessionId . '&course_id=' . $courseId . '&date_to=' . $date_to . '&date_from=' . $date_from; |
|
596 | + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_lp_progress&session_id='.$sessionId.'&course_id='.$courseId.'&date_to='.$date_to.'&date_from='.$date_from; |
|
597 | 597 | |
598 | 598 | //Table Id |
599 | 599 | $tableId = 'lpProgress'; |
@@ -615,11 +615,11 @@ discard block |
||
615 | 615 | true |
616 | 616 | ); |
617 | 617 | |
618 | - $return = '<script>$(function() {'. $table . |
|
618 | + $return = '<script>$(function() {'.$table. |
|
619 | 619 | 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
620 | 620 | jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ |
621 | 621 | caption:"", |
622 | - title:"' . get_lang('ExportExcel') . '", |
|
622 | + title:"' . get_lang('ExportExcel').'", |
|
623 | 623 | onClickButton : function () { |
624 | 624 | jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); |
625 | 625 | } |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | /** |
670 | 670 | * Column config |
671 | 671 | */ |
672 | - $column_model = array( |
|
672 | + $column_model = array( |
|
673 | 673 | array('name'=>'session', 'index'=>'session', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"), |
674 | 674 | array('name'=>'exercise_id', 'index'=>'exercise_id', 'align'=>'left', 'search' => 'true'), |
675 | 675 | array('name'=>'quiz_title', 'index'=>'quiz_title', 'align'=>'left', 'search' => 'true'), |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | //get dynamic column names |
687 | 687 | |
688 | 688 | // jqgrid will use this URL to do the selects |
689 | - $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id=' . $sessionId . '&course_id=' . $courseId . '&exercise_id=' . $exerciseId . '&date_to=' . $date_to . '&date_from=' . $date_from; |
|
689 | + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id='.$sessionId.'&course_id='.$courseId.'&exercise_id='.$exerciseId.'&date_to='.$date_to.'&date_from='.$date_from; |
|
690 | 690 | |
691 | 691 | // Autowidth |
692 | 692 | $extra_params['autowidth'] = 'true'; |
@@ -697,11 +697,11 @@ discard block |
||
697 | 697 | $tableId = 'exerciseProgressOverview'; |
698 | 698 | $table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), '', true); |
699 | 699 | |
700 | - $return = '<script>$(function() {'. $table . |
|
700 | + $return = '<script>$(function() {'.$table. |
|
701 | 701 | 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
702 | 702 | jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ |
703 | 703 | caption:"", |
704 | - title:"' . get_lang('ExportExcel') . '", |
|
704 | + title:"' . get_lang('ExportExcel').'", |
|
705 | 705 | onClickButton : function () { |
706 | 706 | jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); |
707 | 707 | } |
@@ -787,8 +787,8 @@ discard block |
||
787 | 787 | |
788 | 788 | $column[] = $title; |
789 | 789 | $column_model[] = array( |
790 | - 'name' => 'exer' . $i, |
|
791 | - 'index' => 'exer' . $i, |
|
790 | + 'name' => 'exer'.$i, |
|
791 | + 'index' => 'exer'.$i, |
|
792 | 792 | 'align' => 'center', |
793 | 793 | 'search' => 'true', |
794 | 794 | 'wrap_cell' => "true" |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | |
801 | 801 | //end get dynamic column names |
802 | 802 | // jqgrid will use this URL to do the selects |
803 | - $url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_exercise_grade&session_id=' . $sessionId . '&course_id=' . $courseId; |
|
803 | + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_grade&session_id='.$sessionId.'&course_id='.$courseId; |
|
804 | 804 | |
805 | 805 | // Autowidth |
806 | 806 | $extra_params['autowidth'] = 'true'; |
@@ -811,13 +811,13 @@ discard block |
||
811 | 811 | $tableId = 'exerciseGradeOverview'; |
812 | 812 | $table = Display::grid_js($tableId, $url, $column, $column_model, $extra_params, array(), '', true); |
813 | 813 | |
814 | - $return = '<script>$(function() {' . $table . |
|
815 | - 'jQuery("#' . $tableId . '").jqGrid("navGrid","#' . $tableId . '_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
|
816 | - jQuery("#' . $tableId . '").jqGrid("navButtonAdd","#' . $tableId . '_pager",{ |
|
814 | + $return = '<script>$(function() {'.$table. |
|
815 | + 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
|
816 | + jQuery("#' . $tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ |
|
817 | 817 | caption:"", |
818 | - title:"' . get_lang('ExportExcel') . '", |
|
818 | + title:"' . get_lang('ExportExcel').'", |
|
819 | 819 | onClickButton : function () { |
820 | - jQuery("#' . $tableId . '").jqGrid("excelExport",{"url":"' . $url . '&export_format=xls"}); |
|
820 | + jQuery("#' . $tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); |
|
821 | 821 | } |
822 | 822 | }); |
823 | 823 | });</script>'; |
@@ -850,10 +850,10 @@ discard block |
||
850 | 850 | /** |
851 | 851 | * Column config |
852 | 852 | */ |
853 | - $column_model = array( |
|
854 | - array('name'=>'username', 'index'=>'username', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"), |
|
855 | - array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left', 'search' => 'true'), |
|
856 | - array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left', 'search' => 'true'), |
|
853 | + $column_model = array( |
|
854 | + array('name'=>'username', 'index'=>'username', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"), |
|
855 | + array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left', 'search' => 'true'), |
|
856 | + array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left', 'search' => 'true'), |
|
857 | 857 | ); |
858 | 858 | //get dinamic column names |
859 | 859 | foreach ($questions as $question_id => $question) { |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | $action_links = ''; |
870 | 870 | |
871 | 871 | // jqgrid will use this URL to do the selects |
872 | - $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_survey_overview&session_id=' . $sessionId . '&course_id=' . $courseId . '&survey_id=' . $surveyId . '&date_to=' . $date_to . '&date_from=' . $date_from; |
|
872 | + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_survey_overview&session_id='.$sessionId.'&course_id='.$courseId.'&survey_id='.$surveyId.'&date_to='.$date_to.'&date_from='.$date_from; |
|
873 | 873 | |
874 | 874 | // Table Id |
875 | 875 | $tableId = 'lpProgress'; |
@@ -891,11 +891,11 @@ discard block |
||
891 | 891 | true |
892 | 892 | ); |
893 | 893 | |
894 | - $return = '<script>$(function() {'. $table . |
|
894 | + $return = '<script>$(function() {'.$table. |
|
895 | 895 | 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
896 | 896 | jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ |
897 | 897 | caption:"", |
898 | - title:"' . get_lang('ExportExcel') . '", |
|
898 | + title:"' . get_lang('ExportExcel').'", |
|
899 | 899 | onClickButton : function () { |
900 | 900 | jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); |
901 | 901 | } |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | * Display a sortable table that contains an overview off all the progress of the user in a session |
911 | 911 | * @author César Perales <[email protected]>, Beeznest Team |
912 | 912 | */ |
913 | - static function display_tracking_progress_overview($sessionId = 0, $courseId = 0, $date_from, $date_to) |
|
913 | + static function display_tracking_progress_overview($sessionId = 0, $courseId = 0, $date_from, $date_to) |
|
914 | 914 | { |
915 | 915 | //The order is important you need to check the the $column variable in the model.ajax.php file |
916 | 916 | $columns = array( |
@@ -960,55 +960,55 @@ discard block |
||
960 | 960 | ); |
961 | 961 | |
962 | 962 | //Column config |
963 | - $column_model = array( |
|
964 | - array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left'), |
|
965 | - array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left'), |
|
966 | - array('name'=>'username', 'index'=>'username', 'align'=>'left'), |
|
963 | + $column_model = array( |
|
964 | + array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left'), |
|
965 | + array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left'), |
|
966 | + array('name'=>'username', 'index'=>'username', 'align'=>'left'), |
|
967 | 967 | #array('name'=>'profile', 'index'=>'username', 'align'=>'left'), |
968 | - array('name'=>'total', 'index'=>'total', 'align'=>'left'), |
|
969 | - array('name'=>'courses', 'index'=>'courses', 'align'=>'left', 'sortable' => 'false'), |
|
970 | - array('name'=>'lessons', 'index'=>'lessons', 'align'=>'left', 'sortable' => 'false'), |
|
971 | - array('name'=>'exercises', 'index'=>'exercises', 'align'=>'left', 'sortable' => 'false'), |
|
972 | - array('name'=>'forums', 'index'=>'forums', 'align'=>'left', 'sortable' => 'false'), |
|
973 | - array('name'=>'homeworks', 'index'=>'homeworks', 'align'=>'left', 'sortable' => 'false'), |
|
974 | - array('name'=>'wikis', 'index'=>'wikis', 'align'=>'left', 'sortable' => 'false'), |
|
975 | - array('name'=>'surveys', 'index'=>'surveys', 'align'=>'left', 'sortable' => 'false'), |
|
968 | + array('name'=>'total', 'index'=>'total', 'align'=>'left'), |
|
969 | + array('name'=>'courses', 'index'=>'courses', 'align'=>'left', 'sortable' => 'false'), |
|
970 | + array('name'=>'lessons', 'index'=>'lessons', 'align'=>'left', 'sortable' => 'false'), |
|
971 | + array('name'=>'exercises', 'index'=>'exercises', 'align'=>'left', 'sortable' => 'false'), |
|
972 | + array('name'=>'forums', 'index'=>'forums', 'align'=>'left', 'sortable' => 'false'), |
|
973 | + array('name'=>'homeworks', 'index'=>'homeworks', 'align'=>'left', 'sortable' => 'false'), |
|
974 | + array('name'=>'wikis', 'index'=>'wikis', 'align'=>'left', 'sortable' => 'false'), |
|
975 | + array('name'=>'surveys', 'index'=>'surveys', 'align'=>'left', 'sortable' => 'false'), |
|
976 | 976 | //Lessons |
977 | - array('name'=>'lessons_total', 'index'=>'lessons_total', 'align'=>'center', 'sortable' => 'false'), |
|
978 | - array('name'=>'lessons_done', 'index'=>'lessons_done', 'align'=>'center', 'sortable' => 'false'), |
|
979 | - array('name'=>'lessons_left', 'index'=>'lessons_left', 'align'=>'center', 'sortable' => 'false'), |
|
980 | - array('name'=>'lessons_progress', 'index'=>'lessons_progress', 'align'=>'center', 'sortable' => 'false'), |
|
977 | + array('name'=>'lessons_total', 'index'=>'lessons_total', 'align'=>'center', 'sortable' => 'false'), |
|
978 | + array('name'=>'lessons_done', 'index'=>'lessons_done', 'align'=>'center', 'sortable' => 'false'), |
|
979 | + array('name'=>'lessons_left', 'index'=>'lessons_left', 'align'=>'center', 'sortable' => 'false'), |
|
980 | + array('name'=>'lessons_progress', 'index'=>'lessons_progress', 'align'=>'center', 'sortable' => 'false'), |
|
981 | 981 | //Exercises |
982 | - array('name'=>'exercises_total', 'index'=>'exercises_total', 'align'=>'center', 'sortable' => 'false'), |
|
983 | - array('name'=>'exercises_done', 'index'=>'exercises_done', 'align'=>'center', 'sortable' => 'false'), |
|
984 | - array('name'=>'exercises_left', 'index'=>'exercises_left', 'align'=>'center', 'sortable' => 'false'), |
|
985 | - array('name'=>'exercises_progress', 'index'=>'exercises_progress', 'align'=>'center', 'sortable' => 'false'), |
|
982 | + array('name'=>'exercises_total', 'index'=>'exercises_total', 'align'=>'center', 'sortable' => 'false'), |
|
983 | + array('name'=>'exercises_done', 'index'=>'exercises_done', 'align'=>'center', 'sortable' => 'false'), |
|
984 | + array('name'=>'exercises_left', 'index'=>'exercises_left', 'align'=>'center', 'sortable' => 'false'), |
|
985 | + array('name'=>'exercises_progress', 'index'=>'exercises_progress', 'align'=>'center', 'sortable' => 'false'), |
|
986 | 986 | //Assignments |
987 | - array('name'=>'forums_total', 'index'=>'forums_total', 'align'=>'center', 'sortable' => 'false'), |
|
988 | - array('name'=>'forums_done', 'index'=>'forums_done', 'align'=>'center', 'sortable' => 'false'), |
|
989 | - array('name'=>'forums_left', 'index'=>'forums_left', 'align'=>'center', 'sortable' => 'false'), |
|
990 | - array('name'=>'forums_progress', 'index'=>'forums_progress', 'align'=>'center', 'sortable' => 'false'), |
|
987 | + array('name'=>'forums_total', 'index'=>'forums_total', 'align'=>'center', 'sortable' => 'false'), |
|
988 | + array('name'=>'forums_done', 'index'=>'forums_done', 'align'=>'center', 'sortable' => 'false'), |
|
989 | + array('name'=>'forums_left', 'index'=>'forums_left', 'align'=>'center', 'sortable' => 'false'), |
|
990 | + array('name'=>'forums_progress', 'index'=>'forums_progress', 'align'=>'center', 'sortable' => 'false'), |
|
991 | 991 | //Assignments |
992 | - array('name'=>'assigments_total', 'index'=>'assigments_total', 'align'=>'center', 'sortable' => 'false'), |
|
993 | - array('name'=>'assigments_done', 'index'=>'assigments_done', 'align'=>'center', 'sortable' => 'false'), |
|
994 | - array('name'=>'assigments_left', 'index'=>'assigments_left', 'align'=>'center', 'sortable' => 'false'), |
|
995 | - array('name'=>'assigments_progress', 'index'=>'assigments_progress', 'align'=>'center', 'sortable' => 'false'), |
|
992 | + array('name'=>'assigments_total', 'index'=>'assigments_total', 'align'=>'center', 'sortable' => 'false'), |
|
993 | + array('name'=>'assigments_done', 'index'=>'assigments_done', 'align'=>'center', 'sortable' => 'false'), |
|
994 | + array('name'=>'assigments_left', 'index'=>'assigments_left', 'align'=>'center', 'sortable' => 'false'), |
|
995 | + array('name'=>'assigments_progress', 'index'=>'assigments_progress', 'align'=>'center', 'sortable' => 'false'), |
|
996 | 996 | //Assignments |
997 | - array('name'=>'wiki_total', 'index'=>'wiki_total', 'align'=>'center', 'sortable' => 'false'), |
|
998 | - array('name'=>'wiki_revisions', 'index'=>'wiki_revisions', 'align'=>'center', 'sortable' => 'false'), |
|
999 | - array('name'=>'wiki_read', 'index'=>'wiki_read', 'align'=>'center', 'sortable' => 'false'), |
|
1000 | - array('name'=>'wiki_unread', 'index'=>'wiki_unread', 'align'=>'center', 'sortable' => 'false'), |
|
1001 | - array('name'=>'wiki_progress', 'index'=>'wiki_progress', 'align'=>'center', 'sortable' => 'false'), |
|
997 | + array('name'=>'wiki_total', 'index'=>'wiki_total', 'align'=>'center', 'sortable' => 'false'), |
|
998 | + array('name'=>'wiki_revisions', 'index'=>'wiki_revisions', 'align'=>'center', 'sortable' => 'false'), |
|
999 | + array('name'=>'wiki_read', 'index'=>'wiki_read', 'align'=>'center', 'sortable' => 'false'), |
|
1000 | + array('name'=>'wiki_unread', 'index'=>'wiki_unread', 'align'=>'center', 'sortable' => 'false'), |
|
1001 | + array('name'=>'wiki_progress', 'index'=>'wiki_progress', 'align'=>'center', 'sortable' => 'false'), |
|
1002 | 1002 | //Surveys |
1003 | - array('name'=>'surveys_total', 'index'=>'surveys_total', 'align'=>'center', 'sortable' => 'false'), |
|
1004 | - array('name'=>'surveys_done', 'index'=>'surveys_done', 'align'=>'center', 'sortable' => 'false'), |
|
1005 | - array('name'=>'surveys_left', 'index'=>'surveys_left', 'align'=>'center', 'sortable' => 'false'), |
|
1006 | - array('name'=>'surveys_progress', 'index'=>'surveys_progress', 'align'=>'center', 'sortable' => 'false'), |
|
1003 | + array('name'=>'surveys_total', 'index'=>'surveys_total', 'align'=>'center', 'sortable' => 'false'), |
|
1004 | + array('name'=>'surveys_done', 'index'=>'surveys_done', 'align'=>'center', 'sortable' => 'false'), |
|
1005 | + array('name'=>'surveys_left', 'index'=>'surveys_left', 'align'=>'center', 'sortable' => 'false'), |
|
1006 | + array('name'=>'surveys_progress', 'index'=>'surveys_progress', 'align'=>'center', 'sortable' => 'false'), |
|
1007 | 1007 | ); |
1008 | 1008 | |
1009 | 1009 | $action_links = ''; |
1010 | 1010 | // jqgrid will use this URL to do the selects |
1011 | - $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_progress&session_id=' . $sessionId . '&course_id=' . $courseId . '&date_to=' . $date_to . '&date_from=' . $date_from; |
|
1011 | + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_progress&session_id='.$sessionId.'&course_id='.$courseId.'&date_to='.$date_to.'&date_from='.$date_from; |
|
1012 | 1012 | |
1013 | 1013 | //Table Id |
1014 | 1014 | $tableId = 'progressOverview'; |
@@ -1068,11 +1068,11 @@ discard block |
||
1068 | 1068 | true |
1069 | 1069 | ); |
1070 | 1070 | |
1071 | - $return = '<script>$(function() {'. $table . |
|
1071 | + $return = '<script>$(function() {'.$table. |
|
1072 | 1072 | 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
1073 | 1073 | jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ |
1074 | 1074 | caption:"", |
1075 | - title:"' . get_lang('ExportExcel') . '", |
|
1075 | + title:"' . get_lang('ExportExcel').'", |
|
1076 | 1076 | onClickButton : function () { |
1077 | 1077 | jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); |
1078 | 1078 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | // adding the fields that are checked to the session |
1133 | 1133 | $message = ''; |
1134 | 1134 | foreach ($values as $field_ids => $value) { |
1135 | - if ($value == 1 && strstr($field_ids,'extra_export_field')) { |
|
1135 | + if ($value == 1 && strstr($field_ids, 'extra_export_field')) { |
|
1136 | 1136 | $_SESSION['additional_export_fields'][] = str_replace('extra_export_field', '', $field_ids); |
1137 | 1137 | } |
1138 | 1138 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | // Displaying a feedback message |
1148 | 1148 | if (!empty($_SESSION['additional_export_fields'])) { |
1149 | 1149 | Display::display_confirmation_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', false); |
1150 | - } else { |
|
1150 | + } else { |
|
1151 | 1151 | Display::display_confirmation_message(get_lang('NoAdditionalFieldsWillBeExported'), false); |
1152 | 1152 | } |
1153 | 1153 | } else { |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | { |
1176 | 1176 | $t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">'; |
1177 | 1177 | //$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>'; |
1178 | - $t_head .= '<tr>'; |
|
1178 | + $t_head .= '<tr>'; |
|
1179 | 1179 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>'; |
1180 | 1180 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>'; |
1181 | 1181 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgCourseScore'), 6, true).'</span></th>'; |
@@ -1192,13 +1192,13 @@ discard block |
||
1192 | 1192 | |
1193 | 1193 | $addparams = array('view' => 'admin', 'display' => 'courseoverview'); |
1194 | 1194 | |
1195 | - $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_courses'), array('MySpace','get_course_data_tracking_overview'), 1); |
|
1195 | + $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_courses'), array('MySpace', 'get_course_data_tracking_overview'), 1); |
|
1196 | 1196 | $table->additional_parameters = $addparams; |
1197 | 1197 | |
1198 | 1198 | $table->set_header(0, '', false, null, array('style' => 'display: none')); |
1199 | 1199 | $table->set_header(1, get_lang('Course'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt')); |
1200 | 1200 | $table->set_header(2, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;')); |
1201 | - $table->set_column_filter(2, array('MySpace','course_tracking_filter')); |
|
1201 | + $table->set_column_filter(2, array('MySpace', 'course_tracking_filter')); |
|
1202 | 1202 | $table->display(); |
1203 | 1203 | } |
1204 | 1204 | |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | $sql .= " ORDER BY col$column $direction "; |
1235 | 1235 | $sql .= " LIMIT $from,$number_of_items"; |
1236 | 1236 | $result = Database::query($sql); |
1237 | - $return = array (); |
|
1237 | + $return = array(); |
|
1238 | 1238 | while ($course = Database::fetch_row($result)) { |
1239 | 1239 | $return[] = $course; |
1240 | 1240 | } |
@@ -1287,18 +1287,18 @@ discard block |
||
1287 | 1287 | $progress += $progress_tmp[0]; |
1288 | 1288 | $nb_progress_lp += $progress_tmp[1]; |
1289 | 1289 | $score_tmp = Tracking :: get_avg_student_score($row->user_id, $course_code, array(), null, true); |
1290 | - if(is_array($score_tmp)) { |
|
1290 | + if (is_array($score_tmp)) { |
|
1291 | 1291 | $score += $score_tmp[0]; |
1292 | 1292 | $nb_score_lp += $score_tmp[1]; |
1293 | 1293 | } |
1294 | 1294 | $nb_messages += Tracking::count_student_messages($row->user_id, $course_code); |
1295 | 1295 | $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code); |
1296 | 1296 | $last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false); |
1297 | - if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned |
|
1297 | + if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned |
|
1298 | 1298 | $last_login_date = $last_login_date_tmp; |
1299 | - } else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned. |
|
1299 | + } else if ($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned. |
|
1300 | 1300 | // Find the max and assign it to first_login_date |
1301 | - if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
1301 | + if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
1302 | 1302 | $last_login_date = $last_login_date_tmp; |
1303 | 1303 | } |
1304 | 1304 | } |
@@ -1308,27 +1308,27 @@ discard block |
||
1308 | 1308 | $total_score_possible += $exercise_results_tmp['score_possible']; |
1309 | 1309 | $total_questions_answered += $exercise_results_tmp['questions_answered']; |
1310 | 1310 | } |
1311 | - if($nb_progress_lp > 0) { |
|
1311 | + if ($nb_progress_lp > 0) { |
|
1312 | 1312 | $avg_progress = round($progress / $nb_progress_lp, 2); |
1313 | 1313 | } else { |
1314 | 1314 | $avg_progress = 0; |
1315 | 1315 | } |
1316 | - if($nb_score_lp > 0) { |
|
1316 | + if ($nb_score_lp > 0) { |
|
1317 | 1317 | $avg_score = round($score / $nb_score_lp, 2); |
1318 | 1318 | } else { |
1319 | 1319 | $avg_score = '-'; |
1320 | 1320 | } |
1321 | - if($last_login_date) { |
|
1321 | + if ($last_login_date) { |
|
1322 | 1322 | $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); |
1323 | 1323 | } else { |
1324 | 1324 | $last_login_date = '-'; |
1325 | 1325 | } |
1326 | - if($total_score_possible > 0) { |
|
1326 | + if ($total_score_possible > 0) { |
|
1327 | 1327 | $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); |
1328 | 1328 | } else { |
1329 | 1329 | $total_score_percentage = 0; |
1330 | 1330 | } |
1331 | - if($total_score_percentage > 0) { |
|
1331 | + if ($total_score_percentage > 0) { |
|
1332 | 1332 | $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)'; |
1333 | 1333 | } else { |
1334 | 1334 | $total_score = '-'; |
@@ -1436,7 +1436,7 @@ discard block |
||
1436 | 1436 | $progress += $progress_tmp[0]; |
1437 | 1437 | $nb_progress_lp += $progress_tmp[1]; |
1438 | 1438 | $score_tmp = Tracking :: get_avg_student_score($row->user_id, $course_code, array(), null, true); |
1439 | - if(is_array($score_tmp)) { |
|
1439 | + if (is_array($score_tmp)) { |
|
1440 | 1440 | $score += $score_tmp[0]; |
1441 | 1441 | $nb_score_lp += $score_tmp[1]; |
1442 | 1442 | } |
@@ -1444,11 +1444,11 @@ discard block |
||
1444 | 1444 | $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code); |
1445 | 1445 | |
1446 | 1446 | $last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false); |
1447 | - if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. |
|
1447 | + if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. |
|
1448 | 1448 | $last_login_date = $last_login_date_tmp; |
1449 | - } else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. |
|
1449 | + } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. |
|
1450 | 1450 | // Find the max and assign it to first_login_date |
1451 | - if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
1451 | + if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
1452 | 1452 | $last_login_date = $last_login_date_tmp; |
1453 | 1453 | } |
1454 | 1454 | } |
@@ -1458,22 +1458,22 @@ discard block |
||
1458 | 1458 | $total_score_possible += $exercise_results_tmp['score_possible']; |
1459 | 1459 | $total_questions_answered += $exercise_results_tmp['questions_answered']; |
1460 | 1460 | } |
1461 | - if($nb_progress_lp > 0) { |
|
1461 | + if ($nb_progress_lp > 0) { |
|
1462 | 1462 | $avg_progress = round($progress / $nb_progress_lp, 2); |
1463 | 1463 | } else { |
1464 | 1464 | $avg_progress = 0; |
1465 | 1465 | } |
1466 | - if($nb_score_lp > 0) { |
|
1466 | + if ($nb_score_lp > 0) { |
|
1467 | 1467 | $avg_score = round($score / $nb_score_lp, 2); |
1468 | 1468 | } else { |
1469 | 1469 | $avg_score = '-'; |
1470 | 1470 | } |
1471 | - if($last_login_date) { |
|
1471 | + if ($last_login_date) { |
|
1472 | 1472 | $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); |
1473 | 1473 | } else { |
1474 | 1474 | $last_login_date = '-'; |
1475 | 1475 | } |
1476 | - if($total_score_possible > 0) { |
|
1476 | + if ($total_score_possible > 0) { |
|
1477 | 1477 | $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); |
1478 | 1478 | } else { |
1479 | 1479 | $total_score_percentage = 0; |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | { |
1510 | 1510 | $t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">'; |
1511 | 1511 | //$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>'; |
1512 | - $t_head .= '<tr>'; |
|
1512 | + $t_head .= '<tr>'; |
|
1513 | 1513 | $t_head .= ' <th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>'; |
1514 | 1514 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>'; |
1515 | 1515 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>'; |
@@ -1527,7 +1527,7 @@ discard block |
||
1527 | 1527 | |
1528 | 1528 | $addparams = array('view' => 'admin', 'display' => 'sessionoverview'); |
1529 | 1529 | |
1530 | - $table = new SortableTable('tracking_session_overview', array('MySpace','get_total_number_sessions'), array('MySpace','get_session_data_tracking_overview'), 1); |
|
1530 | + $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_sessions'), array('MySpace', 'get_session_data_tracking_overview'), 1); |
|
1531 | 1531 | $table->additional_parameters = $addparams; |
1532 | 1532 | |
1533 | 1533 | $table->set_header(0, '', false, null, array('style' => 'display: none')); |
@@ -1566,7 +1566,7 @@ discard block |
||
1566 | 1566 | $sql .= " ORDER BY col$column $direction "; |
1567 | 1567 | $sql .= " LIMIT $from,$number_of_items"; |
1568 | 1568 | $result = Database::query($sql); |
1569 | - $return = array (); |
|
1569 | + $return = array(); |
|
1570 | 1570 | while ($session = Database::fetch_row($result)) { |
1571 | 1571 | $return[] = $session; |
1572 | 1572 | } |
@@ -1655,10 +1655,10 @@ discard block |
||
1655 | 1655 | if ($last_login_date_tmp != false && $last_login_date == false) { |
1656 | 1656 | // TODO: To be cleaned. |
1657 | 1657 | $last_login_date = $last_login_date_tmp; |
1658 | - } else if($last_login_date_tmp != false && $last_login_date != false) { |
|
1658 | + } else if ($last_login_date_tmp != false && $last_login_date != false) { |
|
1659 | 1659 | // TODO: Repeated previous condition! To be cleaned. |
1660 | 1660 | // Find the max and assign it to first_login_date |
1661 | - if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
1661 | + if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
1662 | 1662 | $last_login_date = $last_login_date_tmp; |
1663 | 1663 | } |
1664 | 1664 | } |
@@ -1668,27 +1668,27 @@ discard block |
||
1668 | 1668 | $total_score_possible += $exercise_results_tmp['score_possible']; |
1669 | 1669 | $total_questions_answered += $exercise_results_tmp['questions_answered']; |
1670 | 1670 | } |
1671 | - if($nb_progress_lp > 0) { |
|
1671 | + if ($nb_progress_lp > 0) { |
|
1672 | 1672 | $avg_progress = round($progress / $nb_progress_lp, 2); |
1673 | 1673 | } else { |
1674 | 1674 | $avg_progress = 0; |
1675 | 1675 | } |
1676 | - if($nb_score_lp > 0) { |
|
1676 | + if ($nb_score_lp > 0) { |
|
1677 | 1677 | $avg_score = round($score / $nb_score_lp, 2); |
1678 | 1678 | } else { |
1679 | 1679 | $avg_score = '-'; |
1680 | 1680 | } |
1681 | - if($last_login_date) { |
|
1681 | + if ($last_login_date) { |
|
1682 | 1682 | $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); |
1683 | 1683 | } else { |
1684 | 1684 | $last_login_date = '-'; |
1685 | 1685 | } |
1686 | - if($total_score_possible > 0) { |
|
1686 | + if ($total_score_possible > 0) { |
|
1687 | 1687 | $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); |
1688 | 1688 | } else { |
1689 | 1689 | $total_score_percentage = 0; |
1690 | 1690 | } |
1691 | - if($total_score_percentage > 0) { |
|
1691 | + if ($total_score_percentage > 0) { |
|
1692 | 1692 | $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)'; |
1693 | 1693 | } else { |
1694 | 1694 | $total_score = '-'; |
@@ -1799,7 +1799,7 @@ discard block |
||
1799 | 1799 | $total_score_obtained = 0; |
1800 | 1800 | $total_score_possible = 0; |
1801 | 1801 | $total_questions_answered = 0; |
1802 | - while($row_user = Database::fetch_object($result_users)) { |
|
1802 | + while ($row_user = Database::fetch_object($result_users)) { |
|
1803 | 1803 | // get time spent in the course and session |
1804 | 1804 | $time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id); |
1805 | 1805 | $progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true); |
@@ -1828,11 +1828,11 @@ discard block |
||
1828 | 1828 | $session_id, |
1829 | 1829 | false |
1830 | 1830 | ); |
1831 | - if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. |
|
1831 | + if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. |
|
1832 | 1832 | $last_login_date = $last_login_date_tmp; |
1833 | - } else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. |
|
1833 | + } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. |
|
1834 | 1834 | // Find the max and assign it to first_login_date |
1835 | - if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
1835 | + if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
1836 | 1836 | $last_login_date = $last_login_date_tmp; |
1837 | 1837 | } |
1838 | 1838 | } |
@@ -1842,27 +1842,27 @@ discard block |
||
1842 | 1842 | $total_score_possible += $exercise_results_tmp['score_possible']; |
1843 | 1843 | $total_questions_answered += $exercise_results_tmp['questions_answered']; |
1844 | 1844 | } |
1845 | - if($nb_progress_lp > 0) { |
|
1845 | + if ($nb_progress_lp > 0) { |
|
1846 | 1846 | $avg_progress = round($progress / $nb_progress_lp, 2); |
1847 | 1847 | } else { |
1848 | 1848 | $avg_progress = 0; |
1849 | 1849 | } |
1850 | - if($nb_score_lp > 0) { |
|
1850 | + if ($nb_score_lp > 0) { |
|
1851 | 1851 | $avg_score = round($score / $nb_score_lp, 2); |
1852 | 1852 | } else { |
1853 | 1853 | $avg_score = '-'; |
1854 | 1854 | } |
1855 | - if($last_login_date) { |
|
1855 | + if ($last_login_date) { |
|
1856 | 1856 | $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); |
1857 | 1857 | } else { |
1858 | 1858 | $last_login_date = '-'; |
1859 | 1859 | } |
1860 | - if($total_score_possible > 0) { |
|
1860 | + if ($total_score_possible > 0) { |
|
1861 | 1861 | $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); |
1862 | 1862 | } else { |
1863 | 1863 | $total_score_percentage = 0; |
1864 | 1864 | } |
1865 | - if($total_score_percentage > 0) { |
|
1865 | + if ($total_score_percentage > 0) { |
|
1866 | 1866 | $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)'; |
1867 | 1867 | } else { |
1868 | 1868 | $total_score = '-'; |
@@ -1912,7 +1912,7 @@ discard block |
||
1912 | 1912 | FROM '.Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES)." |
1913 | 1913 | WHERE c_id = ' . $courseId . ' |
1914 | 1914 | AND exe_user_id = '".intval($user_id)."'"; |
1915 | - if($session_id !== false) { |
|
1915 | + if ($session_id !== false) { |
|
1916 | 1916 | $sql .= " AND session_id = '".$session_id."' "; |
1917 | 1917 | } |
1918 | 1918 | $result = Database::query($sql); |
@@ -1922,7 +1922,7 @@ discard block |
||
1922 | 1922 | while ($row = Database::fetch_array($result)) { |
1923 | 1923 | $score_obtained += $row['exe_result']; |
1924 | 1924 | $score_possible += $row['exe_weighting']; |
1925 | - $questions_answered ++; |
|
1925 | + $questions_answered++; |
|
1926 | 1926 | } |
1927 | 1927 | |
1928 | 1928 | if ($score_possible != 0) { |
@@ -2043,9 +2043,9 @@ discard block |
||
2043 | 2043 | } |
2044 | 2044 | } |
2045 | 2045 | // time spent in the course |
2046 | - $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course ($user[4], $courseId)); |
|
2046 | + $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user[4], $courseId)); |
|
2047 | 2047 | // student progress in course |
2048 | - $csv_row[] = round(Tracking::get_avg_student_progress ($user[4], $row[0]), 2); |
|
2048 | + $csv_row[] = round(Tracking::get_avg_student_progress($user[4], $row[0]), 2); |
|
2049 | 2049 | // student score |
2050 | 2050 | $csv_row[] = round(Tracking::get_avg_student_score($user[4], $row[0]), 2); |
2051 | 2051 | // student tes score |
@@ -2053,7 +2053,7 @@ discard block |
||
2053 | 2053 | // student messages |
2054 | 2054 | $csv_row[] = Tracking::count_student_messages($user[4], $row[0]); |
2055 | 2055 | // student assignments |
2056 | - $csv_row[] = Tracking::count_student_assignments ($user[4], $row[0]); |
|
2056 | + $csv_row[] = Tracking::count_student_assignments($user[4], $row[0]); |
|
2057 | 2057 | // student exercises results |
2058 | 2058 | $exercises_results = MySpace::exercises_results($user[4], $row[0]); |
2059 | 2059 | $csv_row[] = $exercises_results['score_obtained']; |
@@ -2061,7 +2061,7 @@ discard block |
||
2061 | 2061 | $csv_row[] = $exercises_results['questions_answered']; |
2062 | 2062 | $csv_row[] = $exercises_results['percentage']; |
2063 | 2063 | // first connection |
2064 | - $csv_row[] = Tracking::get_first_connection_date_on_the_course ($user[4], $courseId); |
|
2064 | + $csv_row[] = Tracking::get_first_connection_date_on_the_course($user[4], $courseId); |
|
2065 | 2065 | // last connection |
2066 | 2066 | $csv_row[] = strip_tags(Tracking::get_last_connection_date_on_the_course($user[4], $courseInfo)); |
2067 | 2067 | |
@@ -2095,9 +2095,9 @@ discard block |
||
2095 | 2095 | // get all courses with limit |
2096 | 2096 | $sql = "SELECT course.code as col1, course.title as col2 |
2097 | 2097 | FROM $tbl_course course |
2098 | - WHERE course.code IN (".implode(',',$courses_code).")"; |
|
2098 | + WHERE course.code IN (".implode(',', $courses_code).")"; |
|
2099 | 2099 | |
2100 | - if (!in_array($direction, array('ASC','DESC'))) $direction = 'ASC'; |
|
2100 | + if (!in_array($direction, array('ASC', 'DESC'))) $direction = 'ASC'; |
|
2101 | 2101 | |
2102 | 2102 | $column = intval($column); |
2103 | 2103 | $from = intval($from); |
@@ -2166,7 +2166,7 @@ discard block |
||
2166 | 2166 | $table_row[] = $avg_assignments_in_course; |
2167 | 2167 | |
2168 | 2168 | //set the "from" value to know if I access the Reporting by the chamilo tab or the course link |
2169 | - $table_row[] = '<center><a href="../../tracking/courseLog.php?cidReq=' .$course_code.'&from=myspace&id_session='.$session_id.'"> |
|
2169 | + $table_row[] = '<center><a href="../../tracking/courseLog.php?cidReq='.$course_code.'&from=myspace&id_session='.$session_id.'"> |
|
2170 | 2170 | <img src="'.api_get_path(WEB_IMG_PATH).'icons/22/2rightarrow.png" border="0" /></a> |
2171 | 2171 | </center>'; |
2172 | 2172 | $csv_content[] = array( |
@@ -2174,7 +2174,7 @@ discard block |
||
2174 | 2174 | $nb_students_in_course, |
2175 | 2175 | $avg_time_spent_in_course, |
2176 | 2176 | is_null($avg_progress_in_course) ? null : $avg_progress_in_course.'%', |
2177 | - is_null($avg_score_in_course) ? null : is_numeric($avg_score_in_course) ? $avg_score_in_course.'%' : $avg_score_in_course , |
|
2177 | + is_null($avg_score_in_course) ? null : is_numeric($avg_score_in_course) ? $avg_score_in_course.'%' : $avg_score_in_course, |
|
2178 | 2178 | is_null($avg_score_in_exercise) ? null : $avg_score_in_exercise.'%', |
2179 | 2179 | $avg_messages_in_course, |
2180 | 2180 | $avg_assignments_in_course, |
@@ -2242,7 +2242,7 @@ discard block |
||
2242 | 2242 | $sql .= " ORDER BY col$column $direction "; |
2243 | 2243 | $sql .= " LIMIT $from,$number_of_items"; |
2244 | 2244 | $result = Database::query($sql); |
2245 | - $return = array (); |
|
2245 | + $return = array(); |
|
2246 | 2246 | while ($user = Database::fetch_row($result)) { |
2247 | 2247 | $return[] = $user; |
2248 | 2248 | } |
@@ -2297,7 +2297,7 @@ discard block |
||
2297 | 2297 | $i++; |
2298 | 2298 | } |
2299 | 2299 | } |
2300 | - $username_array = array('username' => $desired_username , 'sufix' => $sufix); |
|
2300 | + $username_array = array('username' => $desired_username, 'sufix' => $sufix); |
|
2301 | 2301 | return $username_array; |
2302 | 2302 | } else { |
2303 | 2303 | $username_array = array('username' => $username, 'sufix' => ''); |
@@ -2571,7 +2571,7 @@ discard block |
||
2571 | 2571 | foreach ($users as $index => $user) { |
2572 | 2572 | $userid = $user['id']; |
2573 | 2573 | $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id, registered_at) |
2574 | - VALUES ('$id_session','$userid', '" . api_get_utc_datetime() . "')"; |
|
2574 | + VALUES ('$id_session','$userid', '".api_get_utc_datetime()."')"; |
|
2575 | 2575 | Database::query($sql_insert); |
2576 | 2576 | $user['added_at_session'] = 1; |
2577 | 2577 | $new_users[] = $user; |
@@ -2605,10 +2605,10 @@ discard block |
||
2605 | 2605 | ); |
2606 | 2606 | $userInfo = api_get_user_info($user['id']); |
2607 | 2607 | |
2608 | - if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) { |
|
2608 | + if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) { |
|
2609 | 2609 | if ($user['added_at_platform'] == 1) { |
2610 | 2610 | $addedto = get_lang('UserCreatedPlatform'); |
2611 | - } else { |
|
2611 | + } else { |
|
2612 | 2612 | $addedto = ' '; |
2613 | 2613 | } |
2614 | 2614 | |
@@ -2671,7 +2671,7 @@ discard block |
||
2671 | 2671 | global $current_tag; |
2672 | 2672 | switch ($data) { |
2673 | 2673 | case 'Contact' : |
2674 | - $user = array (); |
|
2674 | + $user = array(); |
|
2675 | 2675 | break; |
2676 | 2676 | default : |
2677 | 2677 | $current_tag = $data; |
@@ -2718,9 +2718,9 @@ discard block |
||
2718 | 2718 | global $current_value; |
2719 | 2719 | global $user; |
2720 | 2720 | global $users; |
2721 | - $users = array (); |
|
2721 | + $users = array(); |
|
2722 | 2722 | $parser = xml_parser_create('UTF-8'); |
2723 | - xml_set_element_handler($parser, array('MySpace','element_start'), array('MySpace','element_end')); |
|
2723 | + xml_set_element_handler($parser, array('MySpace', 'element_start'), array('MySpace', 'element_end')); |
|
2724 | 2724 | xml_set_character_data_handler($parser, "character_data"); |
2725 | 2725 | xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); |
2726 | 2726 | xml_parse($parser, api_utf8_encode_xml(file_get_contents($file))); |
@@ -2766,7 +2766,7 @@ discard block |
||
2766 | 2766 | get_lang('SearchCourse'), |
2767 | 2767 | $courseList, |
2768 | 2768 | [ |
2769 | - 'url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?' . http_build_query([ |
|
2769 | + 'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?'.http_build_query([ |
|
2770 | 2770 | 'a' => 'search_course_by_session_all', |
2771 | 2771 | 'session_id' => $sessionId |
2772 | 2772 | ]) |
@@ -2785,7 +2785,7 @@ discard block |
||
2785 | 2785 | course_id: $('#course_id').val() || 0 |
2786 | 2786 | }); |
2787 | 2787 | |
2788 | - return '" . api_get_path(WEB_AJAX_PATH) . "session.ajax.php?' + params; |
|
2788 | + return '" . api_get_path(WEB_AJAX_PATH)."session.ajax.php?' + params; |
|
2789 | 2789 | } |
2790 | 2790 | " |
2791 | 2791 | ] |
@@ -2816,7 +2816,7 @@ discard block |
||
2816 | 2816 | course_id: $('#course_id').val() |
2817 | 2817 | }); |
2818 | 2818 | |
2819 | - return '" . api_get_path(WEB_AJAX_PATH) . "course.ajax.php?' + params; |
|
2819 | + return '" . api_get_path(WEB_AJAX_PATH)."course.ajax.php?' + params; |
|
2820 | 2820 | } |
2821 | 2821 | " |
2822 | 2822 | ] |
@@ -2842,8 +2842,8 @@ discard block |
||
2842 | 2842 | if ($form->validate()) { |
2843 | 2843 | $table = new SortableTable( |
2844 | 2844 | 'tracking_access_overview', |
2845 | - ['MySpace','getNumberOfRrackingAccessOverview'], |
|
2846 | - ['MySpace','getUserDataAccessTrackingOverview'], |
|
2845 | + ['MySpace', 'getNumberOfRrackingAccessOverview'], |
|
2846 | + ['MySpace', 'getUserDataAccessTrackingOverview'], |
|
2847 | 2847 | 0 |
2848 | 2848 | ); |
2849 | 2849 | $table->additional_parameters = $form->exportValues(); |
@@ -2904,7 +2904,7 @@ discard block |
||
2904 | 2904 | " : " |
2905 | 2905 | u.lastname AS col2, |
2906 | 2906 | u.firstname AS col3, |
2907 | - " ) . " |
|
2907 | + " )." |
|
2908 | 2908 | a.logout_course_date, |
2909 | 2909 | c.title, |
2910 | 2910 | c.code, |
@@ -2915,7 +2915,7 @@ discard block |
||
2915 | 2915 | |
2916 | 2916 | if (isset($_GET['session_id']) && !empty($_GET['session_id'])) { |
2917 | 2917 | $sessionId = intval($_GET['session_id']); |
2918 | - $sql .= " WHERE a.session_id = " . $sessionId; |
|
2918 | + $sql .= " WHERE a.session_id = ".$sessionId; |
|
2919 | 2919 | } |
2920 | 2920 | |
2921 | 2921 | $sql .= " ORDER BY col$column $orderDirection "; |
@@ -2976,14 +2976,14 @@ discard block |
||
2976 | 2976 | function get_stats($user_id, $courseId, $start_date = null, $end_date = null) |
2977 | 2977 | { |
2978 | 2978 | // Database table definitions |
2979 | - $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
2979 | + $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
2980 | 2980 | |
2981 | 2981 | $course_info = api_get_course_info_by_id($courseId); |
2982 | 2982 | if (!empty($course_info)) { |
2983 | 2983 | $strg_sd = ""; |
2984 | 2984 | $strg_ed = ""; |
2985 | - if ($start_date != null && $end_date != null){ |
|
2986 | - $end_date = add_day_to( $end_date ); |
|
2985 | + if ($start_date != null && $end_date != null) { |
|
2986 | + $end_date = add_day_to($end_date); |
|
2987 | 2987 | $strg_sd = "AND login_course_date BETWEEN '$start_date' AND '$end_date'"; |
2988 | 2988 | $strg_ed = "AND logout_course_date BETWEEN '$start_date' AND '$end_date'"; |
2989 | 2989 | } |
@@ -2991,10 +2991,10 @@ discard block |
||
2991 | 2991 | SEC_TO_TIME(avg(time_to_sec(timediff(logout_course_date,login_course_date)))) as avrg, |
2992 | 2992 | SEC_TO_TIME(sum(time_to_sec(timediff(logout_course_date,login_course_date)))) as total, |
2993 | 2993 | count(user_id) as times |
2994 | - FROM ' . $tbl_track_course . ' |
|
2994 | + FROM ' . $tbl_track_course.' |
|
2995 | 2995 | WHERE |
2996 | - user_id = ' . intval($user_id) . ' AND |
|
2997 | - c_id = ' . intval($courseId) . ' '.$strg_sd.' '.$strg_ed.' '.' |
|
2996 | + user_id = ' . intval($user_id).' AND |
|
2997 | + c_id = ' . intval($courseId).' '.$strg_sd.' '.$strg_ed.' '.' |
|
2998 | 2998 | ORDER BY login_course_date ASC'; |
2999 | 2999 | |
3000 | 3000 | $rs = Database::query($sql); |
@@ -3012,7 +3012,7 @@ discard block |
||
3012 | 3012 | } |
3013 | 3013 | |
3014 | 3014 | function add_day_to($end_date) { |
3015 | - $foo_date = strtotime( $end_date ); |
|
3015 | + $foo_date = strtotime($end_date); |
|
3016 | 3016 | $foo_date = strtotime(" +1 day", $foo_date); |
3017 | 3017 | $foo_date = date("Y-m-d", $foo_date); |
3018 | 3018 | return $foo_date; |
@@ -3072,7 +3072,7 @@ discard block |
||
3072 | 3072 | * @version OCT-22- 2010 |
3073 | 3073 | * @return array |
3074 | 3074 | */ |
3075 | -function convert_to_array($sql_result){ |
|
3075 | +function convert_to_array($sql_result) { |
|
3076 | 3076 | $result_to_print = '<table>'; |
3077 | 3077 | foreach ($sql_result as $key => $data) { |
3078 | 3078 | $result_to_print .= '<tr><td>'.date('d-m-Y (H:i:s)', $data['login']).'</td><td>'.api_time_to_hms($data['logout'] - $data['login']).'</tr></td>'."\n"; |
@@ -3091,7 +3091,7 @@ discard block |
||
3091 | 3091 | * @version OCT-22- 2010 |
3092 | 3092 | * @return string |
3093 | 3093 | */ |
3094 | -function convert_to_string($sql_result){ |
|
3094 | +function convert_to_string($sql_result) { |
|
3095 | 3095 | $result_to_print = '<table>'; |
3096 | 3096 | if (!empty($sql_result)) { |
3097 | 3097 | foreach ($sql_result as $key => $data) { |
@@ -3116,18 +3116,18 @@ discard block |
||
3116 | 3116 | */ |
3117 | 3117 | function grapher($sql_result, $start_date, $end_date, $type = "") |
3118 | 3118 | { |
3119 | - if (empty($start_date)) { $start_date =""; } |
|
3120 | - if (empty($end_date)) { $end_date =""; } |
|
3121 | - if ($type == ""){ $type = 'day'; } |
|
3122 | - $main_year = $main_month_year = $main_day = array(); |
|
3119 | + if (empty($start_date)) { $start_date = ""; } |
|
3120 | + if (empty($end_date)) { $end_date = ""; } |
|
3121 | + if ($type == "") { $type = 'day'; } |
|
3122 | + $main_year = $main_month_year = $main_day = array(); |
|
3123 | 3123 | // get last 8 days/months |
3124 | 3124 | $last_days = 5; |
3125 | 3125 | $last_months = 3; |
3126 | 3126 | for ($i = $last_days; $i >= 0; $i--) { |
3127 | - $main_day[date ('d-m-Y', mktime () - $i * 3600 * 24)] = 0; |
|
3127 | + $main_day[date('d-m-Y', mktime() - $i * 3600 * 24)] = 0; |
|
3128 | 3128 | } |
3129 | 3129 | for ($i = $last_months; $i >= 0; $i--) { |
3130 | - $main_month_year[date ('m-Y', mktime () - $i * 30 * 3600 * 24)] = 0; |
|
3130 | + $main_month_year[date('m-Y', mktime() - $i * 30 * 3600 * 24)] = 0; |
|
3131 | 3131 | } |
3132 | 3132 | |
3133 | 3133 | $i = 0; |
@@ -3163,7 +3163,7 @@ discard block |
||
3163 | 3163 | /* Create and populate the pData object */ |
3164 | 3164 | $myData = new pData(); |
3165 | 3165 | $myData->addPoints($main_date, 'Serie1'); |
3166 | - if (count($main_date)!= 1) { |
|
3166 | + if (count($main_date) != 1) { |
|
3167 | 3167 | $myData->addPoints($labels, 'Labels'); |
3168 | 3168 | $myData->setSerieDescription('Labels', 'Months'); |
3169 | 3169 | $myData->setAbscissa('Labels'); |
@@ -3171,7 +3171,7 @@ discard block |
||
3171 | 3171 | $myData->setSerieWeight('Serie1', 1); |
3172 | 3172 | $myData->setSerieDescription('Serie1', get_lang('MyResults')); |
3173 | 3173 | $myData->setAxisName(0, get_lang('Minutes')); |
3174 | - $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true); |
|
3174 | + $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true); |
|
3175 | 3175 | |
3176 | 3176 | // Cache definition |
3177 | 3177 | $cachePath = api_get_path(SYS_ARCHIVE_PATH); |
@@ -3180,9 +3180,9 @@ discard block |
||
3180 | 3180 | |
3181 | 3181 | if ($myCache->isInCache($chartHash)) { |
3182 | 3182 | //if we already created the img |
3183 | - $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; |
|
3183 | + $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash; |
|
3184 | 3184 | $myCache->saveFromCache($chartHash, $imgPath); |
3185 | - $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; |
|
3185 | + $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash; |
|
3186 | 3186 | } else { |
3187 | 3187 | /* Define width, height and angle */ |
3188 | 3188 | $mainWidth = 760; |
@@ -3211,7 +3211,7 @@ discard block |
||
3211 | 3211 | /* Set the default font */ |
3212 | 3212 | $myPicture->setFontProperties( |
3213 | 3213 | array( |
3214 | - "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', |
|
3214 | + "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', |
|
3215 | 3215 | "FontSize" => 10) |
3216 | 3216 | ); |
3217 | 3217 | /* Write the chart title */ |
@@ -3228,7 +3228,7 @@ discard block |
||
3228 | 3228 | /* Set the default font */ |
3229 | 3229 | $myPicture->setFontProperties( |
3230 | 3230 | array( |
3231 | - "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', |
|
3231 | + "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', |
|
3232 | 3232 | "FontSize" => 8 |
3233 | 3233 | ) |
3234 | 3234 | ); |
@@ -3270,7 +3270,7 @@ discard block |
||
3270 | 3270 | /* Draw the line chart */ |
3271 | 3271 | $myPicture->setFontProperties( |
3272 | 3272 | array( |
3273 | - "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', |
|
3273 | + "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', |
|
3274 | 3274 | "FontSize" => 10 |
3275 | 3275 | ) |
3276 | 3276 | ); |
@@ -3289,15 +3289,15 @@ discard block |
||
3289 | 3289 | |
3290 | 3290 | /* Write and save into cache */ |
3291 | 3291 | $myCache->writeToCache($chartHash, $myPicture); |
3292 | - $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; |
|
3292 | + $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash; |
|
3293 | 3293 | $myCache->saveFromCache($chartHash, $imgPath); |
3294 | - $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; |
|
3294 | + $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash; |
|
3295 | 3295 | } |
3296 | - $html = '<img src="' . $imgPath . '">'; |
|
3296 | + $html = '<img src="'.$imgPath.'">'; |
|
3297 | 3297 | |
3298 | 3298 | return $html; |
3299 | 3299 | } else { |
3300 | - $foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>','UTF-8'); |
|
3300 | + $foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>', 'UTF-8'); |
|
3301 | 3301 | |
3302 | 3302 | return $foo_img; |
3303 | 3303 | } |
@@ -2097,7 +2097,9 @@ |
||
2097 | 2097 | FROM $tbl_course course |
2098 | 2098 | WHERE course.code IN (".implode(',',$courses_code).")"; |
2099 | 2099 | |
2100 | - if (!in_array($direction, array('ASC','DESC'))) $direction = 'ASC'; |
|
2100 | + if (!in_array($direction, array('ASC','DESC'))) { |
|
2101 | + $direction = 'ASC'; |
|
2102 | + } |
|
2101 | 2103 | |
2102 | 2104 | $column = intval($column); |
2103 | 2105 | $from = intval($from); |
@@ -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 | { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | ) { |
72 | 72 | mkdir($this->store_path.$this->session_id.'/'.$this->exercise_id.'/'.$this->question_id.'/'.$this->user_id, $directoryPermissions); |
73 | 73 | } |
74 | - } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Setting parameters: course id, session id, etc |
@@ -119,24 +119,24 @@ discard block |
||
119 | 119 | $this->question_id = 0; |
120 | 120 | } |
121 | 121 | |
122 | - $this->can_edit = false; |
|
122 | + $this->can_edit = false; |
|
123 | 123 | |
124 | - if (api_is_allowed_to_edit()) { |
|
125 | - $this->can_edit = true; |
|
126 | - } else { |
|
127 | - if ($this->user_id == api_get_user_id()) { |
|
128 | - $this->can_edit = true; |
|
129 | - } |
|
130 | - } |
|
124 | + if (api_is_allowed_to_edit()) { |
|
125 | + $this->can_edit = true; |
|
126 | + } else { |
|
127 | + if ($this->user_id == api_get_user_id()) { |
|
128 | + $this->can_edit = true; |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - // Settings the params array |
|
133 | - $this->params = $params; |
|
134 | - $this->store_path = api_get_path(SYS_COURSE_PATH).$this->course_info['path'].'/exercises/'; |
|
135 | - $this->create_user_folder(); |
|
136 | - $this->store_path = $this->store_path.implode('/', array($this->session_id, $this->exercise_id, $this->question_id, $this->user_id)).'/'; |
|
137 | - $this->filename = $this->generate_filename(); |
|
138 | - $this->store_filename = $this->store_path.$this->filename; |
|
139 | - } |
|
132 | + // Settings the params array |
|
133 | + $this->params = $params; |
|
134 | + $this->store_path = api_get_path(SYS_COURSE_PATH).$this->course_info['path'].'/exercises/'; |
|
135 | + $this->create_user_folder(); |
|
136 | + $this->store_path = $this->store_path.implode('/', array($this->session_id, $this->exercise_id, $this->question_id, $this->user_id)).'/'; |
|
137 | + $this->filename = $this->generate_filename(); |
|
138 | + $this->store_filename = $this->store_path.$this->filename; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Generates the filename with the next format: |
@@ -187,30 +187,30 @@ discard block |
||
187 | 187 | return $delete_found; |
188 | 188 | } |
189 | 189 | |
190 | - /** |
|
191 | - * |
|
192 | - * Tricky stuff to deal with the feedback = 0 in exercises (all question per page) |
|
190 | + /** |
|
191 | + * |
|
192 | + * Tricky stuff to deal with the feedback = 0 in exercises (all question per page) |
|
193 | 193 | * @param int $exe_id |
194 | - */ |
|
194 | + */ |
|
195 | 195 | public function replace_with_real_exe($exe_id) |
196 | 196 | { |
197 | - $filename = null; |
|
198 | - //@ugly fix |
|
199 | - foreach($this->available_extensions as $extension) { |
|
200 | - $items = explode('-', $this->filename); |
|
201 | - $items[5] = 'temp_exe'; |
|
202 | - $filename = implode('-', $items); |
|
203 | - if (is_file($this->store_path.$filename.'.'.$extension)) { |
|
204 | - $old_name = $this->store_path.$filename.'.'.$extension; |
|
205 | - $items = explode('-', $this->filename); |
|
206 | - $items[5] = $exe_id; |
|
207 | - $filename = $filename = implode('-', $items); |
|
208 | - $new_name = $this->store_path.$filename.'.'.$extension; |
|
209 | - rename($old_name, $new_name); |
|
210 | - break; |
|
211 | - } |
|
212 | - } |
|
213 | - } |
|
197 | + $filename = null; |
|
198 | + //@ugly fix |
|
199 | + foreach($this->available_extensions as $extension) { |
|
200 | + $items = explode('-', $this->filename); |
|
201 | + $items[5] = 'temp_exe'; |
|
202 | + $filename = implode('-', $items); |
|
203 | + if (is_file($this->store_path.$filename.'.'.$extension)) { |
|
204 | + $old_name = $this->store_path.$filename.'.'.$extension; |
|
205 | + $items = explode('-', $this->filename); |
|
206 | + $items[5] = $exe_id; |
|
207 | + $filename = $filename = implode('-', $items); |
|
208 | + $new_name = $this->store_path.$filename.'.'.$extension; |
|
209 | + rename($old_name, $new_name); |
|
210 | + break; |
|
211 | + } |
|
212 | + } |
|
213 | + } |
|
214 | 214 | |
215 | 215 | /** |
216 | 216 | * @param bool $load_from_database |
@@ -218,24 +218,24 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public function load_filename_if_exists($load_from_database = false) |
220 | 220 | { |
221 | - $filename = null; |
|
222 | - //@ugly fix |
|
223 | - foreach($this->available_extensions as $extension) { |
|
224 | - if (is_file($this->store_path.$this->filename.'.'.$extension)) { |
|
225 | - $filename = $this->filename.'.'.$extension; |
|
226 | - break; |
|
227 | - } |
|
228 | - } |
|
221 | + $filename = null; |
|
222 | + //@ugly fix |
|
223 | + foreach($this->available_extensions as $extension) { |
|
224 | + if (is_file($this->store_path.$this->filename.'.'.$extension)) { |
|
225 | + $filename = $this->filename.'.'.$extension; |
|
226 | + break; |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | - // temp_exe |
|
231 | - if ($load_from_database) { |
|
230 | + // temp_exe |
|
231 | + if ($load_from_database) { |
|
232 | 232 | |
233 | - //Load the real filename just if exists |
|
234 | - if (isset($this->params['exe_id']) && isset($this->params['user_id']) && |
|
233 | + //Load the real filename just if exists |
|
234 | + if (isset($this->params['exe_id']) && isset($this->params['user_id']) && |
|
235 | 235 | isset($this->params['question_id']) && isset($this->params['session_id']) && isset($this->params['course_id']) |
236 | 236 | ) { |
237 | - $attempt_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
238 | - $sql = "SELECT filename FROM $attempt_table |
|
237 | + $attempt_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
238 | + $sql = "SELECT filename FROM $attempt_table |
|
239 | 239 | WHERE |
240 | 240 | exe_id = ".$this->params['exe_id']." AND |
241 | 241 | user_id = ".$this->params['user_id']." AND |
@@ -243,107 +243,107 @@ discard block |
||
243 | 243 | session_id = ".$this->params['session_id']." AND |
244 | 244 | course_code = '".$this->course_info['code']."' |
245 | 245 | LIMIT 1"; |
246 | - $result = Database::query($sql); |
|
247 | - $result = Database::fetch_row($result,'ASSOC'); |
|
246 | + $result = Database::query($sql); |
|
247 | + $result = Database::fetch_row($result,'ASSOC'); |
|
248 | 248 | |
249 | - if (isset($result) && isset($result[0]) && !empty($result[0])) { |
|
250 | - $filename = $result[0]; |
|
251 | - } |
|
252 | - } |
|
253 | - } |
|
249 | + if (isset($result) && isset($result[0]) && !empty($result[0])) { |
|
250 | + $filename = $result[0]; |
|
251 | + } |
|
252 | + } |
|
253 | + } |
|
254 | 254 | |
255 | - if (is_file($this->store_path.$filename)) { |
|
256 | - return $this->store_path.$filename; |
|
257 | - } |
|
255 | + if (is_file($this->store_path.$filename)) { |
|
256 | + return $this->store_path.$filename; |
|
257 | + } |
|
258 | 258 | |
259 | - return null; |
|
260 | - } |
|
259 | + return null; |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * |
|
264 | - * Get the URL of the file |
|
265 | - * path courses/XXX/exercises/(session_id)/(exercise_id)/(question_id)/(user_id)/ |
|
262 | + /** |
|
263 | + * |
|
264 | + * Get the URL of the file |
|
265 | + * path courses/XXX/exercises/(session_id)/(exercise_id)/(question_id)/(user_id)/ |
|
266 | 266 | * @param int $force_download |
267 | - * |
|
268 | - * @return string |
|
269 | - */ |
|
267 | + * |
|
268 | + * @return string |
|
269 | + */ |
|
270 | 270 | public function get_public_url($force_download = 0) |
271 | 271 | { |
272 | - $params = $this->get_params(); |
|
273 | - $filename = basename($this->load_filename_if_exists()); |
|
272 | + $params = $this->get_params(); |
|
273 | + $filename = basename($this->load_filename_if_exists()); |
|
274 | 274 | $url = api_get_path(WEB_COURSE_PATH).$this->course_info['path'].'/exercises/'.$params['session_id'].'/'.$params['exercise_id'].'/'.$params['question_id'].'/'.$params['user_id'].'/'.$filename; |
275 | - return $url; |
|
276 | - } |
|
275 | + return $url; |
|
276 | + } |
|
277 | 277 | |
278 | - /** |
|
279 | - * Uploads the nanogong wav file |
|
278 | + /** |
|
279 | + * Uploads the nanogong wav file |
|
280 | 280 | * @param bool |
281 | - */ |
|
282 | - public function upload_file($is_nano = false) |
|
283 | - { |
|
284 | - if (!empty($_FILES)) { |
|
285 | - $upload_ok = process_uploaded_file($_FILES['file'], false); |
|
286 | - |
|
287 | - if (!is_uploaded_file($_FILES['file']['tmp_name'])) { |
|
288 | - return 0; |
|
289 | - } |
|
281 | + */ |
|
282 | + public function upload_file($is_nano = false) |
|
283 | + { |
|
284 | + if (!empty($_FILES)) { |
|
285 | + $upload_ok = process_uploaded_file($_FILES['file'], false); |
|
290 | 286 | |
291 | - if ($upload_ok) { |
|
292 | - // Check if there is enough space to save the file |
|
293 | - if (!DocumentManager::enough_space($_FILES['file']['size'], DocumentManager::get_course_quota())) { |
|
294 | - return 0; |
|
295 | - } |
|
287 | + if (!is_uploaded_file($_FILES['file']['tmp_name'])) { |
|
288 | + return 0; |
|
289 | + } |
|
296 | 290 | |
297 | - //first we delete everything before uploading the file |
|
298 | - $this->delete_files(); |
|
291 | + if ($upload_ok) { |
|
292 | + // Check if there is enough space to save the file |
|
293 | + if (!DocumentManager::enough_space($_FILES['file']['size'], DocumentManager::get_course_quota())) { |
|
294 | + return 0; |
|
295 | + } |
|
299 | 296 | |
300 | - //Reload the filename variable |
|
301 | - $file_name = add_ext_on_mime($_FILES['file']['name'], $_FILES['file']['type']); |
|
302 | - $file_name = strtolower($file_name); |
|
303 | - $file_info = pathinfo($file_name); |
|
297 | + //first we delete everything before uploading the file |
|
298 | + $this->delete_files(); |
|
304 | 299 | |
305 | - if ($is_nano == true) { |
|
306 | - $file_info['extension'] = 'wav'; |
|
307 | - } |
|
300 | + //Reload the filename variable |
|
301 | + $file_name = add_ext_on_mime($_FILES['file']['name'], $_FILES['file']['type']); |
|
302 | + $file_name = strtolower($file_name); |
|
303 | + $file_info = pathinfo($file_name); |
|
308 | 304 | |
309 | - $file_name = $this->filename.'.'.$file_info['extension']; |
|
305 | + if ($is_nano == true) { |
|
306 | + $file_info['extension'] = 'wav'; |
|
307 | + } |
|
310 | 308 | |
311 | - if (in_array($file_info['extension'], $this->available_extensions)) { |
|
312 | - if (move_uploaded_file($_FILES['file']['tmp_name'], $this->store_path.$file_name)) { |
|
313 | - $this->store_filename = $this->store_path.$file_name; |
|
314 | - return 1; |
|
315 | - } |
|
316 | - } |
|
317 | - } |
|
318 | - } |
|
309 | + $file_name = $this->filename.'.'.$file_info['extension']; |
|
310 | + |
|
311 | + if (in_array($file_info['extension'], $this->available_extensions)) { |
|
312 | + if (move_uploaded_file($_FILES['file']['tmp_name'], $this->store_path.$file_name)) { |
|
313 | + $this->store_filename = $this->store_path.$file_name; |
|
314 | + return 1; |
|
315 | + } |
|
316 | + } |
|
317 | + } |
|
318 | + } |
|
319 | 319 | |
320 | - return 0; |
|
321 | - } |
|
320 | + return 0; |
|
321 | + } |
|
322 | 322 | |
323 | - /** |
|
324 | - * Show the audio file + a button to download |
|
323 | + /** |
|
324 | + * Show the audio file + a button to download |
|
325 | 325 | * @param bool |
326 | - */ |
|
327 | - public function show_audio_file($show_delete_button = false) |
|
328 | - { |
|
329 | - $html = ''; |
|
330 | - $file_path = $this->load_filename_if_exists(); |
|
331 | - |
|
332 | - if (!empty($file_path)) { |
|
333 | - $url = $this->get_public_url(true); |
|
334 | - $actions = Display::url(Display::return_icon('save.png', get_lang('Download'), array(), ICON_SIZE_SMALL), $url, array('target'=>'_blank')); |
|
335 | - $download_button = Display::url(get_lang('Download'), $url, array('class' =>'btn btn-default')); |
|
336 | - |
|
337 | - if ($show_delete_button) { |
|
338 | - $actions .= ' '.Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), "#", array('onclick'=>'delete_file();')); |
|
339 | - } |
|
326 | + */ |
|
327 | + public function show_audio_file($show_delete_button = false) |
|
328 | + { |
|
329 | + $html = ''; |
|
330 | + $file_path = $this->load_filename_if_exists(); |
|
331 | + |
|
332 | + if (!empty($file_path)) { |
|
333 | + $url = $this->get_public_url(true); |
|
334 | + $actions = Display::url(Display::return_icon('save.png', get_lang('Download'), array(), ICON_SIZE_SMALL), $url, array('target'=>'_blank')); |
|
335 | + $download_button = Display::url(get_lang('Download'), $url, array('class' =>'btn btn-default')); |
|
340 | 336 | |
341 | - $basename = basename($file_path); |
|
342 | - $path_info = pathinfo($basename); |
|
337 | + if ($show_delete_button) { |
|
338 | + $actions .= ' '.Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), "#", array('onclick'=>'delete_file();')); |
|
339 | + } |
|
343 | 340 | |
344 | - if ($path_info['extension'] == 'wav') { |
|
341 | + $basename = basename($file_path); |
|
342 | + $path_info = pathinfo($basename); |
|
345 | 343 | |
346 | - $html .= '<script> |
|
344 | + if ($path_info['extension'] == 'wav') { |
|
345 | + |
|
346 | + $html .= '<script> |
|
347 | 347 | $(document).ready( function() { |
348 | 348 | var java_enabled = navigator.javaEnabled(); |
349 | 349 | |
@@ -357,56 +357,56 @@ discard block |
||
357 | 357 | }); |
358 | 358 | </script>'; |
359 | 359 | |
360 | - $html .= '<div id="nanogong_player_id" class="nanogong_player_container">'; |
|
361 | - $html .= '<div class="action_player">'.$actions.'</div>'; |
|
362 | - $html .= '<div class="nanogong_player">'; |
|
363 | - $html .= '<applet id="nanogong_player" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" ALIGN="middle">'; |
|
364 | - $html .= '<param name="ShowRecordButton" value="false" />'; // default true |
|
365 | - $html .= '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
366 | - //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
367 | - $html .= '<param name="ShowTime" value="true" />'; // default false |
|
368 | - $html .= '<param name="Color" value="#FFFFFF" />'; |
|
360 | + $html .= '<div id="nanogong_player_id" class="nanogong_player_container">'; |
|
361 | + $html .= '<div class="action_player">'.$actions.'</div>'; |
|
362 | + $html .= '<div class="nanogong_player">'; |
|
363 | + $html .= '<applet id="nanogong_player" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" ALIGN="middle">'; |
|
364 | + $html .= '<param name="ShowRecordButton" value="false" />'; // default true |
|
365 | + $html .= '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
366 | + //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
367 | + $html .= '<param name="ShowTime" value="true" />'; // default false |
|
368 | + $html .= '<param name="Color" value="#FFFFFF" />'; |
|
369 | 369 | $html .= '<param name="ShowSpeedButton" value="false" />'; |
370 | - //echo '<param name="StartTime" value="10.5" />'; |
|
371 | - //echo '<param name="EndTime" value="65" />'; |
|
372 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
373 | - //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
374 | - //Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
375 | - //echo '<param name="SamplingRate" value="32000" />'; |
|
376 | - //echo '<param name="MaxDuration" value="60" />'; |
|
377 | - $html .= '<param name="SoundFileURL" value="'.$url.'" />';//load a file |(default "") |
|
378 | - $html .= '</applet>'; |
|
379 | - $html .= '</div>'; |
|
380 | - $html .= '</div>'; |
|
370 | + //echo '<param name="StartTime" value="10.5" />'; |
|
371 | + //echo '<param name="EndTime" value="65" />'; |
|
372 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
373 | + //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
374 | + //Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
375 | + //echo '<param name="SamplingRate" value="32000" />'; |
|
376 | + //echo '<param name="MaxDuration" value="60" />'; |
|
377 | + $html .= '<param name="SoundFileURL" value="'.$url.'" />';//load a file |(default "") |
|
378 | + $html .= '</applet>'; |
|
379 | + $html .= '</div>'; |
|
380 | + $html .= '</div>'; |
|
381 | 381 | $html .= '<div id="nanogong_warning">'.Display::return_message(get_lang('BrowserDoesNotSupportNanogongPlayer'), 'warning').$download_button.'</div>'; |
382 | 382 | |
383 | - } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { |
|
384 | - $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
|
385 | - $html .= '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/blue.monday/css/jplayer.blue.monday.css" type="text/css">'; |
|
386 | - $html .= '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>'; |
|
383 | + } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { |
|
384 | + $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
|
385 | + $html .= '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/blue.monday/css/jplayer.blue.monday.css" type="text/css">'; |
|
386 | + $html .= '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>'; |
|
387 | 387 | |
388 | - $html .= '<div class="nanogong_player"></div>'; |
|
389 | - $html .= '<br /><div class="action_player">'.$actions.'</div><br /><br /><br />'; |
|
388 | + $html .= '<div class="nanogong_player"></div>'; |
|
389 | + $html .= '<br /><div class="action_player">'.$actions.'</div><br /><br /><br />'; |
|
390 | 390 | |
391 | 391 | $params = array( |
392 | 392 | 'url' => $url, |
393 | 393 | 'extension' =>$path_info['extension'], |
394 | 394 | 'count'=> 1 |
395 | - ); |
|
395 | + ); |
|
396 | 396 | $jquery = DocumentManager::generate_jplayer_jquery($params); |
397 | - $html .= '<script> |
|
397 | + $html .= '<script> |
|
398 | 398 | $(document).ready( function() { |
399 | 399 | //Experimental changes to preview mp3, ogg files |
400 | 400 | '.$jquery.' |
401 | 401 | }); |
402 | 402 | </script>'; |
403 | - $html .= DocumentManager::generate_media_preview(1, 'advanced'); |
|
404 | - } |
|
405 | - } |
|
403 | + $html .= DocumentManager::generate_media_preview(1, 'advanced'); |
|
404 | + } |
|
405 | + } |
|
406 | 406 | return $html; |
407 | - } |
|
407 | + } |
|
408 | 408 | |
409 | - /* |
|
409 | + /* |
|
410 | 410 | var filename = document.getElementById("audio_title").value+".wav"; |
411 | 411 | var filename = filename.replace(/\s/g, "_");//replace spaces by _ |
412 | 412 | var filename = encodeURIComponent(filename); |
@@ -416,19 +416,19 @@ discard block |
||
416 | 416 | var urlnanogong="'.$url.'?filename="+filename+"&filepath="+filepath+"&dir="+dir+"&course_code="+course_code; |
417 | 417 | */ |
418 | 418 | |
419 | - /** |
|
420 | - * Returns the nanogong javascript code |
|
421 | - * @return string |
|
422 | - */ |
|
419 | + /** |
|
420 | + * Returns the nanogong javascript code |
|
421 | + * @return string |
|
422 | + */ |
|
423 | 423 | public function return_js() |
424 | 424 | { |
425 | - $params = $this->get_params(true); |
|
426 | - $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params.'&is_nano=1'; |
|
427 | - $url_load_file = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=show_audio&'.$params; |
|
425 | + $params = $this->get_params(true); |
|
426 | + $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params.'&is_nano=1'; |
|
427 | + $url_load_file = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=show_audio&'.$params; |
|
428 | 428 | |
429 | - $url_delete = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=delete&'.$params; |
|
429 | + $url_delete = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=delete&'.$params; |
|
430 | 430 | |
431 | - $js = '<script language="javascript"> |
|
431 | + $js = '<script language="javascript"> |
|
432 | 432 | |
433 | 433 | //lang vars |
434 | 434 | |
@@ -544,77 +544,77 @@ discard block |
||
544 | 544 | return false; |
545 | 545 | } |
546 | 546 | </script>'; |
547 | - return $js; |
|
548 | - } |
|
547 | + return $js; |
|
548 | + } |
|
549 | 549 | |
550 | - /** |
|
551 | - * Returns the HTML form to upload a nano file or upload a file |
|
550 | + /** |
|
551 | + * Returns the HTML form to upload a nano file or upload a file |
|
552 | 552 | * @param string |
553 | - */ |
|
554 | - public function return_form($message = null) |
|
553 | + */ |
|
554 | + public function return_form($message = null) |
|
555 | 555 | { |
556 | 556 | |
557 | - $params = $this->get_params(true); |
|
558 | - $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params; |
|
557 | + $params = $this->get_params(true); |
|
558 | + $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params; |
|
559 | 559 | |
560 | - //check browser support and load form |
|
561 | - $array_browser = api_browser_support('check_browser'); |
|
560 | + //check browser support and load form |
|
561 | + $array_browser = api_browser_support('check_browser'); |
|
562 | 562 | |
563 | - $preview_file = $this->show_audio_file(true, true); |
|
563 | + $preview_file = $this->show_audio_file(true, true); |
|
564 | 564 | |
565 | 565 | $preview_file = Display::div( |
566 | 566 | $preview_file, |
567 | 567 | array('id' => 'preview', 'style' => 'text-align:center; padding-left: 25px;') |
568 | 568 | ); |
569 | 569 | |
570 | - $html = '<center>'; |
|
570 | + $html = '<center>'; |
|
571 | 571 | |
572 | - //Use normal upload file |
|
573 | - $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'),'', ICON_SIZE_BIG); |
|
574 | - $html .='<br />'; |
|
572 | + //Use normal upload file |
|
573 | + $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'),'', ICON_SIZE_BIG); |
|
574 | + $html .='<br />'; |
|
575 | 575 | |
576 | - $html .= '<div id="nanogong_div">'; |
|
576 | + $html .= '<div id="nanogong_div">'; |
|
577 | 577 | |
578 | - $html .= '<applet id="nanogong" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" align="middle">'; |
|
579 | - //echo '<param name="ShowRecordButton" value="false" />'; // default true |
|
580 | - // echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
578 | + $html .= '<applet id="nanogong" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" align="middle">'; |
|
579 | + //echo '<param name="ShowRecordButton" value="false" />'; // default true |
|
580 | + // echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
581 | 581 | $html .= '<param name="ShowSpeedButton" value="false" />'; // default true |
582 | - //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
583 | - $html .= '<param name="ShowTime" value="true" />'; // default false |
|
584 | - $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF |
|
585 | - //echo '<param name="StartTime" value="10.5" />'; |
|
586 | - //echo '<param name="EndTime" value="65" />'; |
|
587 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
588 | - //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
582 | + //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
583 | + $html .= '<param name="ShowTime" value="true" />'; // default false |
|
584 | + $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF |
|
585 | + //echo '<param name="StartTime" value="10.5" />'; |
|
586 | + //echo '<param name="EndTime" value="65" />'; |
|
587 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
588 | + //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
589 | 589 | |
590 | - //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
591 | - //echo '<param name="MaxDuration" value="60" />'; |
|
592 | - //echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "") |
|
593 | - $html .= '</applet>'; |
|
590 | + //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
591 | + //echo '<param name="MaxDuration" value="60" />'; |
|
592 | + //echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "") |
|
593 | + $html .= '</applet>'; |
|
594 | 594 | |
595 | - $html .= '<br /><br /><br />'; |
|
595 | + $html .= '<br /><br /><br />'; |
|
596 | 596 | |
597 | 597 | $html .= '<form name="form_nanogong_advanced">'; |
598 | - $html .= '<input type="hidden" name="is_nano" value="1">'; |
|
599 | - $html .= '<a href="#" class="btn btn-default" onclick="send_voice()" />'.get_lang('SendRecord').'</a>'; |
|
600 | - $html .= '</form></div>'; |
|
598 | + $html .= '<input type="hidden" name="is_nano" value="1">'; |
|
599 | + $html .= '<a href="#" class="btn btn-default" onclick="send_voice()" />'.get_lang('SendRecord').'</a>'; |
|
600 | + $html .= '</form></div>'; |
|
601 | 601 | |
602 | 602 | $html .= Display::url(get_lang('ProblemsRecordingUploadYourOwnAudioFile'), 'javascript:void(0)', array('onclick' => 'show_simple_upload_form();')); |
603 | 603 | |
604 | - $html .= '<br /><br /><div id="no_nanogong_div">'; |
|
605 | - //$html .= Display::return_message(get_lang('BrowserNotSupportNanogongSend'), 'warning'); |
|
606 | - $html .= '<form id="form_nanogong_simple" class="form-search" action="'.$url.'" name="form_nanogong" method="POST" enctype="multipart/form-data">'; |
|
607 | - $html .= '<input type="file" name="file">'; |
|
608 | - $html .= '<a href="#" class="btn btn-default" onclick="upload_file()" /><em class="fa fa-upload"></em> '.get_lang('UploadFile').'</a>'; |
|
609 | - $html .= '</form>'; |
|
604 | + $html .= '<br /><br /><div id="no_nanogong_div">'; |
|
605 | + //$html .= Display::return_message(get_lang('BrowserNotSupportNanogongSend'), 'warning'); |
|
606 | + $html .= '<form id="form_nanogong_simple" class="form-search" action="'.$url.'" name="form_nanogong" method="POST" enctype="multipart/form-data">'; |
|
607 | + $html .= '<input type="file" name="file">'; |
|
608 | + $html .= '<a href="#" class="btn btn-default" onclick="upload_file()" /><em class="fa fa-upload"></em> '.get_lang('UploadFile').'</a>'; |
|
609 | + $html .= '</form>'; |
|
610 | 610 | $html .= '</div>'; |
611 | - $html .= '</center>'; |
|
612 | - $html .= '<div style="display:none" id="status_ok" class="confirmation-message"></div><div style="display:none" id="status_warning" class="warning-message"></div>'; |
|
613 | - $html .= '<div id="messages">'.$message.'</div>'; |
|
614 | - $html .= $preview_file; |
|
611 | + $html .= '</center>'; |
|
612 | + $html .= '<div style="display:none" id="status_ok" class="confirmation-message"></div><div style="display:none" id="status_warning" class="warning-message"></div>'; |
|
613 | + $html .= '<div id="messages">'.$message.'</div>'; |
|
614 | + $html .= $preview_file; |
|
615 | 615 | |
616 | - return $html; |
|
617 | - } |
|
616 | + return $html; |
|
617 | + } |
|
618 | 618 | |
619 | 619 | /** |
620 | 620 | * @param bool $return_as_query |
@@ -622,15 +622,15 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public function get_params($return_as_query = false) |
624 | 624 | { |
625 | - if (empty($this->params)) { |
|
626 | - return false; |
|
627 | - } |
|
628 | - if ($return_as_query) { |
|
629 | - return http_build_query($this->params); |
|
630 | - } |
|
625 | + if (empty($this->params)) { |
|
626 | + return false; |
|
627 | + } |
|
628 | + if ($return_as_query) { |
|
629 | + return http_build_query($this->params); |
|
630 | + } |
|
631 | 631 | |
632 | - return $this->params; |
|
633 | - } |
|
632 | + return $this->params; |
|
633 | + } |
|
634 | 634 | |
635 | 635 | /** |
636 | 636 | * @param $attribute |
@@ -638,18 +638,18 @@ discard block |
||
638 | 638 | */ |
639 | 639 | public function get_param_value($attribute) |
640 | 640 | { |
641 | - if (isset($this->params[$attribute])) { |
|
642 | - return $this->params[$attribute]; |
|
643 | - } |
|
644 | - } |
|
645 | - |
|
646 | - /** |
|
647 | - * Show a button to load the form |
|
648 | - * @return string |
|
649 | - */ |
|
641 | + if (isset($this->params[$attribute])) { |
|
642 | + return $this->params[$attribute]; |
|
643 | + } |
|
644 | + } |
|
645 | + |
|
646 | + /** |
|
647 | + * Show a button to load the form |
|
648 | + * @return string |
|
649 | + */ |
|
650 | 650 | public function show_button() |
651 | 651 | { |
652 | - $params_string = $this->get_params(true); |
|
652 | + $params_string = $this->get_params(true); |
|
653 | 653 | |
654 | 654 | $url = api_get_path(WEB_AJAX_PATH) |
655 | 655 | . 'nanogong.ajax.php?a=show_form&' |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | 'data-title' => get_lang('RecordAnswer') |
665 | 665 | ] |
666 | 666 | ); |
667 | - $html .= '<br /><br />'.Display::return_message(get_lang('UseTheMessageBelowToAddSomeComments')); |
|
668 | - return $html; |
|
669 | - } |
|
667 | + $html .= '<br /><br />'.Display::return_message(get_lang('UseTheMessageBelowToAddSomeComments')); |
|
668 | + return $html; |
|
669 | + } |
|
670 | 670 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | if (api_is_allowed_to_edit()) { |
125 | 125 | $this->can_edit = true; |
126 | 126 | } else { |
127 | - if ($this->user_id == api_get_user_id()) { |
|
127 | + if ($this->user_id == api_get_user_id()) { |
|
128 | 128 | $this->can_edit = true; |
129 | 129 | } |
130 | 130 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | { |
197 | 197 | $filename = null; |
198 | 198 | //@ugly fix |
199 | - foreach($this->available_extensions as $extension) { |
|
199 | + foreach ($this->available_extensions as $extension) { |
|
200 | 200 | $items = explode('-', $this->filename); |
201 | 201 | $items[5] = 'temp_exe'; |
202 | 202 | $filename = implode('-', $items); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | { |
221 | 221 | $filename = null; |
222 | 222 | //@ugly fix |
223 | - foreach($this->available_extensions as $extension) { |
|
223 | + foreach ($this->available_extensions as $extension) { |
|
224 | 224 | if (is_file($this->store_path.$this->filename.'.'.$extension)) { |
225 | 225 | $filename = $this->filename.'.'.$extension; |
226 | 226 | break; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | course_code = '".$this->course_info['code']."' |
245 | 245 | LIMIT 1"; |
246 | 246 | $result = Database::query($sql); |
247 | - $result = Database::fetch_row($result,'ASSOC'); |
|
247 | + $result = Database::fetch_row($result, 'ASSOC'); |
|
248 | 248 | |
249 | 249 | if (isset($result) && isset($result[0]) && !empty($result[0])) { |
250 | 250 | $filename = $result[0]; |
@@ -369,18 +369,18 @@ discard block |
||
369 | 369 | $html .= '<param name="ShowSpeedButton" value="false" />'; |
370 | 370 | //echo '<param name="StartTime" value="10.5" />'; |
371 | 371 | //echo '<param name="EndTime" value="65" />'; |
372 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
372 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />'; // ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
373 | 373 | //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
374 | 374 | //Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
375 | 375 | //echo '<param name="SamplingRate" value="32000" />'; |
376 | 376 | //echo '<param name="MaxDuration" value="60" />'; |
377 | - $html .= '<param name="SoundFileURL" value="'.$url.'" />';//load a file |(default "") |
|
377 | + $html .= '<param name="SoundFileURL" value="'.$url.'" />'; //load a file |(default "") |
|
378 | 378 | $html .= '</applet>'; |
379 | 379 | $html .= '</div>'; |
380 | 380 | $html .= '</div>'; |
381 | 381 | $html .= '<div id="nanogong_warning">'.Display::return_message(get_lang('BrowserDoesNotSupportNanogongPlayer'), 'warning').$download_button.'</div>'; |
382 | 382 | |
383 | - } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { |
|
383 | + } elseif (in_array($path_info['extension'], array('mp3', 'ogg', 'wav'))) { |
|
384 | 384 | $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
385 | 385 | $html .= '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/blue.monday/css/jplayer.blue.monday.css" type="text/css">'; |
386 | 386 | $html .= '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>'; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | |
429 | 429 | $url_delete = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=delete&'.$params; |
430 | 430 | |
431 | - $js = '<script language="javascript"> |
|
431 | + $js = '<script language="javascript"> |
|
432 | 432 | |
433 | 433 | //lang vars |
434 | 434 | |
@@ -570,8 +570,8 @@ discard block |
||
570 | 570 | $html = '<center>'; |
571 | 571 | |
572 | 572 | //Use normal upload file |
573 | - $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'),'', ICON_SIZE_BIG); |
|
574 | - $html .='<br />'; |
|
573 | + $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'), '', ICON_SIZE_BIG); |
|
574 | + $html .= '<br />'; |
|
575 | 575 | |
576 | 576 | $html .= '<div id="nanogong_div">'; |
577 | 577 | |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF |
585 | 585 | //echo '<param name="StartTime" value="10.5" />'; |
586 | 586 | //echo '<param name="EndTime" value="65" />'; |
587 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
587 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />'; // ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
588 | 588 | //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
589 | 589 | |
590 | 590 | //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
@@ -219,7 +219,7 @@ |
||
219 | 219 | * @param array $user_list recipients: user list of ids |
220 | 220 | * @param string $title |
221 | 221 | * @param string $content |
222 | - * @param array $sender_info |
|
222 | + * @param array $senderInfo |
|
223 | 223 | * result of api_get_user_info() or GroupPortalManager:get_group_data() |
224 | 224 | */ |
225 | 225 | public function save_notification( |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $newMessageText = ''; |
356 | 356 | $linkToNewMessage = Display::url( |
357 | 357 | get_lang('SeeMessage'), |
358 | - api_get_path(WEB_CODE_PATH) . 'messages/inbox.php' |
|
358 | + api_get_path(WEB_CODE_PATH).'messages/inbox.php' |
|
359 | 359 | ); |
360 | 360 | break; |
361 | 361 | case self::NOTIFICATION_TYPE_MESSAGE: |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | } |
371 | 371 | $linkToNewMessage = Display::url( |
372 | 372 | get_lang('SeeMessage'), |
373 | - api_get_path(WEB_CODE_PATH) . 'messages/inbox.php' |
|
373 | + api_get_path(WEB_CODE_PATH).'messages/inbox.php' |
|
374 | 374 | ); |
375 | 375 | break; |
376 | 376 | case self::NOTIFICATION_TYPE_INVITATION: |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | $linkToNewMessage = Display::url( |
387 | 387 | get_lang('SeeInvitation'), |
388 | - api_get_path(WEB_CODE_PATH) . 'social/invitations.php' |
|
388 | + api_get_path(WEB_CODE_PATH).'social/invitations.php' |
|
389 | 389 | ); |
390 | 390 | break; |
391 | 391 | case self::NOTIFICATION_TYPE_GROUP: |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | /** |
307 | 307 | * gets the current debug data for this instance |
308 | 308 | * |
309 | - * @return debug data |
|
309 | + * @return string data |
|
310 | 310 | * @access public |
311 | 311 | */ |
312 | 312 | function &getDebug() { |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * gets the current debug data for this instance as an XML comment |
320 | 320 | * this may change the contents of the debug data |
321 | 321 | * |
322 | - * @return debug data as an XML comment |
|
322 | + * @return string data as an XML comment |
|
323 | 323 | * @access public |
324 | 324 | */ |
325 | 325 | function &getDebugAsXMLComment() { |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | /** |
353 | 353 | * returns error string if present |
354 | 354 | * |
355 | - * @return mixed error string or false |
|
355 | + * @return string|false error string or false |
|
356 | 356 | * @access public |
357 | 357 | */ |
358 | 358 | function getError(){ |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | /** |
366 | 366 | * sets error string |
367 | 367 | * |
368 | - * @return boolean $string error string |
|
368 | + * @return boolean|null $string error string |
|
369 | 369 | * @access private |
370 | 370 | */ |
371 | 371 | function setError($str){ |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | * returns false, if not prefixed |
802 | 802 | * |
803 | 803 | * @param string $str The prefixed string |
804 | - * @return mixed The prefix or false if there is no prefix |
|
804 | + * @return string|false The prefix or false if there is no prefix |
|
805 | 805 | * @access public |
806 | 806 | */ |
807 | 807 | function getPrefix($str){ |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | * or false if no prefixes registered for the given namespace |
833 | 833 | * |
834 | 834 | * @param string $ns The namespace |
835 | - * @return mixed The prefix, false if the namespace has no prefixes |
|
835 | + * @return string The prefix, false if the namespace has no prefixes |
|
836 | 836 | * @access public |
837 | 837 | */ |
838 | 838 | function getPrefixFromNamespace($ns) { |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | * |
899 | 899 | * @param int $timestamp Unix time stamp |
900 | 900 | * @param boolean $utc Whether the time stamp is UTC or local |
901 | -* @return mixed ISO 8601 date string or false |
|
901 | +* @return string|false ISO 8601 date string or false |
|
902 | 902 | * @access public |
903 | 903 | */ |
904 | 904 | function timestamp_to_iso8601($timestamp,$utc=true){ |
@@ -83,810 +83,810 @@ discard block |
||
83 | 83 | * @access public |
84 | 84 | */ |
85 | 85 | class nusoap_base { |
86 | - /** |
|
87 | - * Identification for HTTP headers. |
|
88 | - * |
|
89 | - * @var string |
|
90 | - * @access private |
|
91 | - */ |
|
92 | - var $title = 'NuSOAP'; |
|
93 | - /** |
|
94 | - * Version for HTTP headers. |
|
95 | - * |
|
96 | - * @var string |
|
97 | - * @access private |
|
98 | - */ |
|
99 | - var $version = '0.9.5'; |
|
100 | - /** |
|
101 | - * CVS revision for HTTP headers. |
|
102 | - * |
|
103 | - * @var string |
|
104 | - * @access private |
|
105 | - */ |
|
106 | - var $revision = '$Revision: 1.56 $'; |
|
86 | + /** |
|
87 | + * Identification for HTTP headers. |
|
88 | + * |
|
89 | + * @var string |
|
90 | + * @access private |
|
91 | + */ |
|
92 | + var $title = 'NuSOAP'; |
|
93 | + /** |
|
94 | + * Version for HTTP headers. |
|
95 | + * |
|
96 | + * @var string |
|
97 | + * @access private |
|
98 | + */ |
|
99 | + var $version = '0.9.5'; |
|
100 | + /** |
|
101 | + * CVS revision for HTTP headers. |
|
102 | + * |
|
103 | + * @var string |
|
104 | + * @access private |
|
105 | + */ |
|
106 | + var $revision = '$Revision: 1.56 $'; |
|
107 | 107 | /** |
108 | 108 | * Current error string (manipulated by getError/setError) |
109 | - * |
|
110 | - * @var string |
|
111 | - * @access private |
|
112 | - */ |
|
113 | - var $error_str = ''; |
|
109 | + * |
|
110 | + * @var string |
|
111 | + * @access private |
|
112 | + */ |
|
113 | + var $error_str = ''; |
|
114 | 114 | /** |
115 | 115 | * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) |
116 | - * |
|
117 | - * @var string |
|
118 | - * @access private |
|
119 | - */ |
|
116 | + * |
|
117 | + * @var string |
|
118 | + * @access private |
|
119 | + */ |
|
120 | 120 | var $debug_str = ''; |
121 | 121 | /** |
122 | - * toggles automatic encoding of special characters as entities |
|
123 | - * (should always be true, I think) |
|
124 | - * |
|
125 | - * @var boolean |
|
126 | - * @access private |
|
127 | - */ |
|
128 | - var $charencoding = true; |
|
129 | - /** |
|
130 | - * the debug level for this instance |
|
131 | - * |
|
132 | - * @var integer |
|
133 | - * @access private |
|
134 | - */ |
|
135 | - var $debugLevel; |
|
136 | - |
|
137 | - /** |
|
138 | - * set schema version |
|
139 | - * |
|
140 | - * @var string |
|
141 | - * @access public |
|
142 | - */ |
|
143 | - var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; |
|
144 | - |
|
145 | - /** |
|
146 | - * charset encoding for outgoing messages |
|
147 | - * |
|
148 | - * @var string |
|
149 | - * @access public |
|
150 | - */ |
|
122 | + * toggles automatic encoding of special characters as entities |
|
123 | + * (should always be true, I think) |
|
124 | + * |
|
125 | + * @var boolean |
|
126 | + * @access private |
|
127 | + */ |
|
128 | + var $charencoding = true; |
|
129 | + /** |
|
130 | + * the debug level for this instance |
|
131 | + * |
|
132 | + * @var integer |
|
133 | + * @access private |
|
134 | + */ |
|
135 | + var $debugLevel; |
|
136 | + |
|
137 | + /** |
|
138 | + * set schema version |
|
139 | + * |
|
140 | + * @var string |
|
141 | + * @access public |
|
142 | + */ |
|
143 | + var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; |
|
144 | + |
|
145 | + /** |
|
146 | + * charset encoding for outgoing messages |
|
147 | + * |
|
148 | + * @var string |
|
149 | + * @access public |
|
150 | + */ |
|
151 | 151 | var $soap_defencoding = 'ISO-8859-1'; |
152 | - //var $soap_defencoding = 'UTF-8'; |
|
153 | - |
|
154 | - /** |
|
155 | - * namespaces in an array of prefix => uri |
|
156 | - * |
|
157 | - * this is "seeded" by a set of constants, but it may be altered by code |
|
158 | - * |
|
159 | - * @var array |
|
160 | - * @access public |
|
161 | - */ |
|
162 | - var $namespaces = array( |
|
163 | - 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', |
|
164 | - 'xsd' => 'http://www.w3.org/2001/XMLSchema', |
|
165 | - 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
|
166 | - 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' |
|
167 | - ); |
|
168 | - |
|
169 | - /** |
|
170 | - * namespaces used in the current context, e.g. during serialization |
|
171 | - * |
|
172 | - * @var array |
|
173 | - * @access private |
|
174 | - */ |
|
175 | - var $usedNamespaces = array(); |
|
176 | - |
|
177 | - /** |
|
178 | - * XML Schema types in an array of uri => (array of xml type => php type) |
|
179 | - * is this legacy yet? |
|
180 | - * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. |
|
181 | - * @var array |
|
182 | - * @access public |
|
183 | - */ |
|
184 | - var $typemap = array( |
|
185 | - 'http://www.w3.org/2001/XMLSchema' => array( |
|
186 | - 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
|
187 | - 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', |
|
188 | - 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', |
|
189 | - // abstract "any" types |
|
190 | - 'anyType'=>'string','anySimpleType'=>'string', |
|
191 | - // derived datatypes |
|
192 | - 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', |
|
193 | - 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', |
|
194 | - 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', |
|
195 | - 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), |
|
196 | - 'http://www.w3.org/2000/10/XMLSchema' => array( |
|
197 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
198 | - 'float'=>'double','dateTime'=>'string', |
|
199 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
200 | - 'http://www.w3.org/1999/XMLSchema' => array( |
|
201 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
202 | - 'float'=>'double','dateTime'=>'string', |
|
203 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
204 | - 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), |
|
205 | - 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), |
|
152 | + //var $soap_defencoding = 'UTF-8'; |
|
153 | + |
|
154 | + /** |
|
155 | + * namespaces in an array of prefix => uri |
|
156 | + * |
|
157 | + * this is "seeded" by a set of constants, but it may be altered by code |
|
158 | + * |
|
159 | + * @var array |
|
160 | + * @access public |
|
161 | + */ |
|
162 | + var $namespaces = array( |
|
163 | + 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', |
|
164 | + 'xsd' => 'http://www.w3.org/2001/XMLSchema', |
|
165 | + 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
|
166 | + 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' |
|
167 | + ); |
|
168 | + |
|
169 | + /** |
|
170 | + * namespaces used in the current context, e.g. during serialization |
|
171 | + * |
|
172 | + * @var array |
|
173 | + * @access private |
|
174 | + */ |
|
175 | + var $usedNamespaces = array(); |
|
176 | + |
|
177 | + /** |
|
178 | + * XML Schema types in an array of uri => (array of xml type => php type) |
|
179 | + * is this legacy yet? |
|
180 | + * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. |
|
181 | + * @var array |
|
182 | + * @access public |
|
183 | + */ |
|
184 | + var $typemap = array( |
|
185 | + 'http://www.w3.org/2001/XMLSchema' => array( |
|
186 | + 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
|
187 | + 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', |
|
188 | + 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', |
|
189 | + // abstract "any" types |
|
190 | + 'anyType'=>'string','anySimpleType'=>'string', |
|
191 | + // derived datatypes |
|
192 | + 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', |
|
193 | + 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', |
|
194 | + 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', |
|
195 | + 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), |
|
196 | + 'http://www.w3.org/2000/10/XMLSchema' => array( |
|
197 | + 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
198 | + 'float'=>'double','dateTime'=>'string', |
|
199 | + 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
200 | + 'http://www.w3.org/1999/XMLSchema' => array( |
|
201 | + 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
202 | + 'float'=>'double','dateTime'=>'string', |
|
203 | + 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
204 | + 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), |
|
205 | + 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), |
|
206 | 206 | 'http://xml.apache.org/xml-soap' => array('Map') |
207 | - ); |
|
208 | - |
|
209 | - /** |
|
210 | - * XML entities to convert |
|
211 | - * |
|
212 | - * @var array |
|
213 | - * @access public |
|
214 | - * @deprecated |
|
215 | - * @see expandEntities |
|
216 | - */ |
|
217 | - var $xmlEntities = array('quot' => '"','amp' => '&', |
|
218 | - 'lt' => '<','gt' => '>','apos' => "'"); |
|
219 | - |
|
220 | - /** |
|
221 | - * constructor |
|
222 | - * |
|
223 | - * @access public |
|
224 | - */ |
|
225 | - function nusoap_base() { |
|
226 | - $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * gets the global debug level, which applies to future instances |
|
231 | - * |
|
232 | - * @return integer Debug level 0-9, where 0 turns off |
|
233 | - * @access public |
|
234 | - */ |
|
235 | - function getGlobalDebugLevel() { |
|
236 | - return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * sets the global debug level, which applies to future instances |
|
241 | - * |
|
242 | - * @param int $level Debug level 0-9, where 0 turns off |
|
243 | - * @access public |
|
244 | - */ |
|
245 | - function setGlobalDebugLevel($level) { |
|
246 | - $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * gets the debug level for this instance |
|
251 | - * |
|
252 | - * @return int Debug level 0-9, where 0 turns off |
|
253 | - * @access public |
|
254 | - */ |
|
255 | - function getDebugLevel() { |
|
256 | - return $this->debugLevel; |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * sets the debug level for this instance |
|
261 | - * |
|
262 | - * @param int $level Debug level 0-9, where 0 turns off |
|
263 | - * @access public |
|
264 | - */ |
|
265 | - function setDebugLevel($level) { |
|
266 | - $this->debugLevel = $level; |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * adds debug data to the instance debug string with formatting |
|
271 | - * |
|
272 | - * @param string $string debug data |
|
273 | - * @access private |
|
274 | - */ |
|
275 | - function debug($string){ |
|
276 | - if ($this->debugLevel > 0) { |
|
277 | - $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
|
278 | - } |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * adds debug data to the instance debug string without formatting |
|
283 | - * |
|
284 | - * @param string $string debug data |
|
285 | - * @access public |
|
286 | - */ |
|
287 | - function appendDebug($string){ |
|
288 | - if ($this->debugLevel > 0) { |
|
289 | - // it would be nice to use a memory stream here to use |
|
290 | - // memory more efficiently |
|
291 | - $this->debug_str .= $string; |
|
292 | - } |
|
293 | - } |
|
294 | - |
|
295 | - /** |
|
296 | - * clears the current debug data for this instance |
|
297 | - * |
|
298 | - * @access public |
|
299 | - */ |
|
300 | - function clearDebug() { |
|
301 | - // it would be nice to use a memory stream here to use |
|
302 | - // memory more efficiently |
|
303 | - $this->debug_str = ''; |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * gets the current debug data for this instance |
|
308 | - * |
|
309 | - * @return debug data |
|
310 | - * @access public |
|
311 | - */ |
|
312 | - function &getDebug() { |
|
313 | - // it would be nice to use a memory stream here to use |
|
314 | - // memory more efficiently |
|
315 | - return $this->debug_str; |
|
316 | - } |
|
317 | - |
|
318 | - /** |
|
319 | - * gets the current debug data for this instance as an XML comment |
|
320 | - * this may change the contents of the debug data |
|
321 | - * |
|
322 | - * @return debug data as an XML comment |
|
323 | - * @access public |
|
324 | - */ |
|
325 | - function &getDebugAsXMLComment() { |
|
326 | - // it would be nice to use a memory stream here to use |
|
327 | - // memory more efficiently |
|
328 | - while (strpos($this->debug_str, '--')) { |
|
329 | - $this->debug_str = str_replace('--', '- -', $this->debug_str); |
|
330 | - } |
|
331 | - $ret = "<!--\n" . $this->debug_str . "\n-->"; |
|
332 | - return $ret; |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * expands entities, e.g. changes '<' to '<'. |
|
337 | - * |
|
338 | - * @param string $val The string in which to expand entities. |
|
339 | - * @access private |
|
340 | - */ |
|
341 | - function expandEntities($val) { |
|
342 | - if ($this->charencoding) { |
|
343 | - $val = str_replace('&', '&', $val); |
|
344 | - $val = str_replace("'", ''', $val); |
|
345 | - $val = str_replace('"', '"', $val); |
|
346 | - $val = str_replace('<', '<', $val); |
|
347 | - $val = str_replace('>', '>', $val); |
|
348 | - } |
|
349 | - return $val; |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * returns error string if present |
|
354 | - * |
|
355 | - * @return mixed error string or false |
|
356 | - * @access public |
|
357 | - */ |
|
358 | - function getError(){ |
|
359 | - if($this->error_str != ''){ |
|
360 | - return $this->error_str; |
|
361 | - } |
|
362 | - return false; |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * sets error string |
|
367 | - * |
|
368 | - * @return boolean $string error string |
|
369 | - * @access private |
|
370 | - */ |
|
371 | - function setError($str){ |
|
372 | - $this->error_str = $str; |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * detect if array is a simple array or a struct (associative array) |
|
377 | - * |
|
378 | - * @param mixed $val The PHP array |
|
379 | - * @return string (arraySimple|arrayStruct) |
|
380 | - * @access private |
|
381 | - */ |
|
382 | - function isArraySimpleOrStruct($val) { |
|
207 | + ); |
|
208 | + |
|
209 | + /** |
|
210 | + * XML entities to convert |
|
211 | + * |
|
212 | + * @var array |
|
213 | + * @access public |
|
214 | + * @deprecated |
|
215 | + * @see expandEntities |
|
216 | + */ |
|
217 | + var $xmlEntities = array('quot' => '"','amp' => '&', |
|
218 | + 'lt' => '<','gt' => '>','apos' => "'"); |
|
219 | + |
|
220 | + /** |
|
221 | + * constructor |
|
222 | + * |
|
223 | + * @access public |
|
224 | + */ |
|
225 | + function nusoap_base() { |
|
226 | + $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * gets the global debug level, which applies to future instances |
|
231 | + * |
|
232 | + * @return integer Debug level 0-9, where 0 turns off |
|
233 | + * @access public |
|
234 | + */ |
|
235 | + function getGlobalDebugLevel() { |
|
236 | + return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
237 | + } |
|
238 | + |
|
239 | + /** |
|
240 | + * sets the global debug level, which applies to future instances |
|
241 | + * |
|
242 | + * @param int $level Debug level 0-9, where 0 turns off |
|
243 | + * @access public |
|
244 | + */ |
|
245 | + function setGlobalDebugLevel($level) { |
|
246 | + $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * gets the debug level for this instance |
|
251 | + * |
|
252 | + * @return int Debug level 0-9, where 0 turns off |
|
253 | + * @access public |
|
254 | + */ |
|
255 | + function getDebugLevel() { |
|
256 | + return $this->debugLevel; |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * sets the debug level for this instance |
|
261 | + * |
|
262 | + * @param int $level Debug level 0-9, where 0 turns off |
|
263 | + * @access public |
|
264 | + */ |
|
265 | + function setDebugLevel($level) { |
|
266 | + $this->debugLevel = $level; |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * adds debug data to the instance debug string with formatting |
|
271 | + * |
|
272 | + * @param string $string debug data |
|
273 | + * @access private |
|
274 | + */ |
|
275 | + function debug($string){ |
|
276 | + if ($this->debugLevel > 0) { |
|
277 | + $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
|
278 | + } |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * adds debug data to the instance debug string without formatting |
|
283 | + * |
|
284 | + * @param string $string debug data |
|
285 | + * @access public |
|
286 | + */ |
|
287 | + function appendDebug($string){ |
|
288 | + if ($this->debugLevel > 0) { |
|
289 | + // it would be nice to use a memory stream here to use |
|
290 | + // memory more efficiently |
|
291 | + $this->debug_str .= $string; |
|
292 | + } |
|
293 | + } |
|
294 | + |
|
295 | + /** |
|
296 | + * clears the current debug data for this instance |
|
297 | + * |
|
298 | + * @access public |
|
299 | + */ |
|
300 | + function clearDebug() { |
|
301 | + // it would be nice to use a memory stream here to use |
|
302 | + // memory more efficiently |
|
303 | + $this->debug_str = ''; |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * gets the current debug data for this instance |
|
308 | + * |
|
309 | + * @return debug data |
|
310 | + * @access public |
|
311 | + */ |
|
312 | + function &getDebug() { |
|
313 | + // it would be nice to use a memory stream here to use |
|
314 | + // memory more efficiently |
|
315 | + return $this->debug_str; |
|
316 | + } |
|
317 | + |
|
318 | + /** |
|
319 | + * gets the current debug data for this instance as an XML comment |
|
320 | + * this may change the contents of the debug data |
|
321 | + * |
|
322 | + * @return debug data as an XML comment |
|
323 | + * @access public |
|
324 | + */ |
|
325 | + function &getDebugAsXMLComment() { |
|
326 | + // it would be nice to use a memory stream here to use |
|
327 | + // memory more efficiently |
|
328 | + while (strpos($this->debug_str, '--')) { |
|
329 | + $this->debug_str = str_replace('--', '- -', $this->debug_str); |
|
330 | + } |
|
331 | + $ret = "<!--\n" . $this->debug_str . "\n-->"; |
|
332 | + return $ret; |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * expands entities, e.g. changes '<' to '<'. |
|
337 | + * |
|
338 | + * @param string $val The string in which to expand entities. |
|
339 | + * @access private |
|
340 | + */ |
|
341 | + function expandEntities($val) { |
|
342 | + if ($this->charencoding) { |
|
343 | + $val = str_replace('&', '&', $val); |
|
344 | + $val = str_replace("'", ''', $val); |
|
345 | + $val = str_replace('"', '"', $val); |
|
346 | + $val = str_replace('<', '<', $val); |
|
347 | + $val = str_replace('>', '>', $val); |
|
348 | + } |
|
349 | + return $val; |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * returns error string if present |
|
354 | + * |
|
355 | + * @return mixed error string or false |
|
356 | + * @access public |
|
357 | + */ |
|
358 | + function getError(){ |
|
359 | + if($this->error_str != ''){ |
|
360 | + return $this->error_str; |
|
361 | + } |
|
362 | + return false; |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * sets error string |
|
367 | + * |
|
368 | + * @return boolean $string error string |
|
369 | + * @access private |
|
370 | + */ |
|
371 | + function setError($str){ |
|
372 | + $this->error_str = $str; |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * detect if array is a simple array or a struct (associative array) |
|
377 | + * |
|
378 | + * @param mixed $val The PHP array |
|
379 | + * @return string (arraySimple|arrayStruct) |
|
380 | + * @access private |
|
381 | + */ |
|
382 | + function isArraySimpleOrStruct($val) { |
|
383 | 383 | $keyList = array_keys($val); |
384 | - foreach ($keyList as $keyListValue) { |
|
385 | - if (!is_int($keyListValue)) { |
|
386 | - return 'arrayStruct'; |
|
387 | - } |
|
388 | - } |
|
389 | - return 'arraySimple'; |
|
390 | - } |
|
391 | - |
|
392 | - /** |
|
393 | - * serializes PHP values in accordance w/ section 5. Type information is |
|
394 | - * not serialized if $use == 'literal'. |
|
395 | - * |
|
396 | - * @param mixed $val The value to serialize |
|
397 | - * @param string $name The name (local part) of the XML element |
|
398 | - * @param string $type The XML schema type (local part) for the element |
|
399 | - * @param string $name_ns The namespace for the name of the XML element |
|
400 | - * @param string $type_ns The namespace for the type of the element |
|
401 | - * @param array $attributes The attributes to serialize as name=>value pairs |
|
402 | - * @param string $use The WSDL "use" (encoded|literal) |
|
403 | - * @param boolean $soapval Whether this is called from soapval. |
|
404 | - * @return string The serialized element, possibly with child elements |
|
405 | - * @access public |
|
406 | - */ |
|
407 | - function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) { |
|
408 | - $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); |
|
409 | - $this->appendDebug('value=' . $this->varDump($val)); |
|
410 | - $this->appendDebug('attributes=' . $this->varDump($attributes)); |
|
411 | - |
|
412 | - if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { |
|
413 | - $this->debug("serialize_val: serialize soapval"); |
|
414 | - $xml = $val->serialize($use); |
|
415 | - $this->appendDebug($val->getDebug()); |
|
416 | - $val->clearDebug(); |
|
417 | - $this->debug("serialize_val of soapval returning $xml"); |
|
418 | - return $xml; |
|
384 | + foreach ($keyList as $keyListValue) { |
|
385 | + if (!is_int($keyListValue)) { |
|
386 | + return 'arrayStruct'; |
|
387 | + } |
|
419 | 388 | } |
420 | - // force valid name if necessary |
|
421 | - if (is_numeric($name)) { |
|
422 | - $name = '__numeric_' . $name; |
|
423 | - } elseif (! $name) { |
|
424 | - $name = 'noname'; |
|
425 | - } |
|
426 | - // if name has ns, add ns prefix to name |
|
427 | - $xmlns = ''; |
|
389 | + return 'arraySimple'; |
|
390 | + } |
|
391 | + |
|
392 | + /** |
|
393 | + * serializes PHP values in accordance w/ section 5. Type information is |
|
394 | + * not serialized if $use == 'literal'. |
|
395 | + * |
|
396 | + * @param mixed $val The value to serialize |
|
397 | + * @param string $name The name (local part) of the XML element |
|
398 | + * @param string $type The XML schema type (local part) for the element |
|
399 | + * @param string $name_ns The namespace for the name of the XML element |
|
400 | + * @param string $type_ns The namespace for the type of the element |
|
401 | + * @param array $attributes The attributes to serialize as name=>value pairs |
|
402 | + * @param string $use The WSDL "use" (encoded|literal) |
|
403 | + * @param boolean $soapval Whether this is called from soapval. |
|
404 | + * @return string The serialized element, possibly with child elements |
|
405 | + * @access public |
|
406 | + */ |
|
407 | + function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) { |
|
408 | + $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); |
|
409 | + $this->appendDebug('value=' . $this->varDump($val)); |
|
410 | + $this->appendDebug('attributes=' . $this->varDump($attributes)); |
|
411 | + |
|
412 | + if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { |
|
413 | + $this->debug("serialize_val: serialize soapval"); |
|
414 | + $xml = $val->serialize($use); |
|
415 | + $this->appendDebug($val->getDebug()); |
|
416 | + $val->clearDebug(); |
|
417 | + $this->debug("serialize_val of soapval returning $xml"); |
|
418 | + return $xml; |
|
419 | + } |
|
420 | + // force valid name if necessary |
|
421 | + if (is_numeric($name)) { |
|
422 | + $name = '__numeric_' . $name; |
|
423 | + } elseif (! $name) { |
|
424 | + $name = 'noname'; |
|
425 | + } |
|
426 | + // if name has ns, add ns prefix to name |
|
427 | + $xmlns = ''; |
|
428 | 428 | if($name_ns){ |
429 | - $prefix = 'nu'.rand(1000,9999); |
|
430 | - $name = $prefix.':'.$name; |
|
431 | - $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
|
432 | - } |
|
433 | - // if type is prefixed, create type prefix |
|
434 | - if($type_ns != '' && $type_ns == $this->namespaces['xsd']){ |
|
435 | - // need to fix this. shouldn't default to xsd if no ns specified |
|
436 | - // w/o checking against typemap |
|
437 | - $type_prefix = 'xsd'; |
|
438 | - } elseif($type_ns){ |
|
439 | - $type_prefix = 'ns'.rand(1000,9999); |
|
440 | - $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; |
|
441 | - } |
|
442 | - // serialize attributes if present |
|
443 | - $atts = ''; |
|
444 | - if($attributes){ |
|
445 | - foreach($attributes as $k => $v){ |
|
446 | - $atts .= " $k=\"".$this->expandEntities($v).'"'; |
|
447 | - } |
|
448 | - } |
|
449 | - // serialize null value |
|
450 | - if (is_null($val)) { |
|
451 | - $this->debug("serialize_val: serialize null"); |
|
452 | - if ($use == 'literal') { |
|
453 | - // TODO: depends on minOccurs |
|
454 | - $xml = "<$name$xmlns$atts/>"; |
|
455 | - $this->debug("serialize_val returning $xml"); |
|
456 | - return $xml; |
|
457 | - } else { |
|
458 | - if (isset($type) && isset($type_prefix)) { |
|
459 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
460 | - } else { |
|
461 | - $type_str = ''; |
|
462 | - } |
|
463 | - $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; |
|
464 | - $this->debug("serialize_val returning $xml"); |
|
465 | - return $xml; |
|
466 | - } |
|
467 | - } |
|
429 | + $prefix = 'nu'.rand(1000,9999); |
|
430 | + $name = $prefix.':'.$name; |
|
431 | + $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
|
432 | + } |
|
433 | + // if type is prefixed, create type prefix |
|
434 | + if($type_ns != '' && $type_ns == $this->namespaces['xsd']){ |
|
435 | + // need to fix this. shouldn't default to xsd if no ns specified |
|
436 | + // w/o checking against typemap |
|
437 | + $type_prefix = 'xsd'; |
|
438 | + } elseif($type_ns){ |
|
439 | + $type_prefix = 'ns'.rand(1000,9999); |
|
440 | + $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; |
|
441 | + } |
|
442 | + // serialize attributes if present |
|
443 | + $atts = ''; |
|
444 | + if($attributes){ |
|
445 | + foreach($attributes as $k => $v){ |
|
446 | + $atts .= " $k=\"".$this->expandEntities($v).'"'; |
|
447 | + } |
|
448 | + } |
|
449 | + // serialize null value |
|
450 | + if (is_null($val)) { |
|
451 | + $this->debug("serialize_val: serialize null"); |
|
452 | + if ($use == 'literal') { |
|
453 | + // TODO: depends on minOccurs |
|
454 | + $xml = "<$name$xmlns$atts/>"; |
|
455 | + $this->debug("serialize_val returning $xml"); |
|
456 | + return $xml; |
|
457 | + } else { |
|
458 | + if (isset($type) && isset($type_prefix)) { |
|
459 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
460 | + } else { |
|
461 | + $type_str = ''; |
|
462 | + } |
|
463 | + $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; |
|
464 | + $this->debug("serialize_val returning $xml"); |
|
465 | + return $xml; |
|
466 | + } |
|
467 | + } |
|
468 | 468 | // serialize if an xsd built-in primitive type |
469 | 469 | if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){ |
470 | - $this->debug("serialize_val: serialize xsd built-in primitive type"); |
|
471 | - if (is_bool($val)) { |
|
472 | - if ($type == 'boolean') { |
|
473 | - $val = $val ? 'true' : 'false'; |
|
474 | - } elseif (! $val) { |
|
475 | - $val = 0; |
|
476 | - } |
|
477 | - } else if (is_string($val)) { |
|
478 | - $val = $this->expandEntities($val); |
|
479 | - } |
|
480 | - if ($use == 'literal') { |
|
481 | - $xml = "<$name$xmlns$atts>$val</$name>"; |
|
482 | - $this->debug("serialize_val returning $xml"); |
|
483 | - return $xml; |
|
484 | - } else { |
|
485 | - $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>"; |
|
486 | - $this->debug("serialize_val returning $xml"); |
|
487 | - return $xml; |
|
488 | - } |
|
470 | + $this->debug("serialize_val: serialize xsd built-in primitive type"); |
|
471 | + if (is_bool($val)) { |
|
472 | + if ($type == 'boolean') { |
|
473 | + $val = $val ? 'true' : 'false'; |
|
474 | + } elseif (! $val) { |
|
475 | + $val = 0; |
|
476 | + } |
|
477 | + } else if (is_string($val)) { |
|
478 | + $val = $this->expandEntities($val); |
|
479 | + } |
|
480 | + if ($use == 'literal') { |
|
481 | + $xml = "<$name$xmlns$atts>$val</$name>"; |
|
482 | + $this->debug("serialize_val returning $xml"); |
|
483 | + return $xml; |
|
484 | + } else { |
|
485 | + $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>"; |
|
486 | + $this->debug("serialize_val returning $xml"); |
|
487 | + return $xml; |
|
488 | + } |
|
489 | 489 | } |
490 | - // detect type and serialize |
|
491 | - $xml = ''; |
|
492 | - switch(true) { |
|
493 | - case (is_bool($val) || $type == 'boolean'): |
|
494 | - $this->debug("serialize_val: serialize boolean"); |
|
495 | - if ($type == 'boolean') { |
|
496 | - $val = $val ? 'true' : 'false'; |
|
497 | - } elseif (! $val) { |
|
498 | - $val = 0; |
|
499 | - } |
|
500 | - if ($use == 'literal') { |
|
501 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
502 | - } else { |
|
503 | - $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>"; |
|
504 | - } |
|
505 | - break; |
|
506 | - case (is_int($val) || is_long($val) || $type == 'int'): |
|
507 | - $this->debug("serialize_val: serialize int"); |
|
508 | - if ($use == 'literal') { |
|
509 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
510 | - } else { |
|
511 | - $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>"; |
|
512 | - } |
|
513 | - break; |
|
514 | - case (is_float($val)|| is_double($val) || $type == 'float'): |
|
515 | - $this->debug("serialize_val: serialize float"); |
|
516 | - if ($use == 'literal') { |
|
517 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
518 | - } else { |
|
519 | - $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>"; |
|
520 | - } |
|
521 | - break; |
|
522 | - case (is_string($val) || $type == 'string'): |
|
523 | - $this->debug("serialize_val: serialize string"); |
|
524 | - $val = $this->expandEntities($val); |
|
525 | - if ($use == 'literal') { |
|
526 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
527 | - } else { |
|
528 | - $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>"; |
|
529 | - } |
|
530 | - break; |
|
531 | - case is_object($val): |
|
532 | - $this->debug("serialize_val: serialize object"); |
|
533 | - if (get_class($val) == 'soapval') { |
|
534 | - $this->debug("serialize_val: serialize soapval object"); |
|
535 | - $pXml = $val->serialize($use); |
|
536 | - $this->appendDebug($val->getDebug()); |
|
537 | - $val->clearDebug(); |
|
538 | - } else { |
|
539 | - if (! $name) { |
|
540 | - $name = get_class($val); |
|
541 | - $this->debug("In serialize_val, used class name $name as element name"); |
|
542 | - } else { |
|
543 | - $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val)); |
|
544 | - } |
|
545 | - foreach(get_object_vars($val) as $k => $v){ |
|
546 | - $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); |
|
547 | - } |
|
548 | - } |
|
549 | - if(isset($type) && isset($type_prefix)){ |
|
550 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
551 | - } else { |
|
552 | - $type_str = ''; |
|
553 | - } |
|
554 | - if ($use == 'literal') { |
|
555 | - $xml .= "<$name$xmlns$atts>$pXml</$name>"; |
|
556 | - } else { |
|
557 | - $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>"; |
|
558 | - } |
|
559 | - break; |
|
560 | - break; |
|
561 | - case (is_array($val) || $type): |
|
562 | - // detect if struct or array |
|
563 | - $valueType = $this->isArraySimpleOrStruct($val); |
|
490 | + // detect type and serialize |
|
491 | + $xml = ''; |
|
492 | + switch(true) { |
|
493 | + case (is_bool($val) || $type == 'boolean'): |
|
494 | + $this->debug("serialize_val: serialize boolean"); |
|
495 | + if ($type == 'boolean') { |
|
496 | + $val = $val ? 'true' : 'false'; |
|
497 | + } elseif (! $val) { |
|
498 | + $val = 0; |
|
499 | + } |
|
500 | + if ($use == 'literal') { |
|
501 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
502 | + } else { |
|
503 | + $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>"; |
|
504 | + } |
|
505 | + break; |
|
506 | + case (is_int($val) || is_long($val) || $type == 'int'): |
|
507 | + $this->debug("serialize_val: serialize int"); |
|
508 | + if ($use == 'literal') { |
|
509 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
510 | + } else { |
|
511 | + $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>"; |
|
512 | + } |
|
513 | + break; |
|
514 | + case (is_float($val)|| is_double($val) || $type == 'float'): |
|
515 | + $this->debug("serialize_val: serialize float"); |
|
516 | + if ($use == 'literal') { |
|
517 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
518 | + } else { |
|
519 | + $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>"; |
|
520 | + } |
|
521 | + break; |
|
522 | + case (is_string($val) || $type == 'string'): |
|
523 | + $this->debug("serialize_val: serialize string"); |
|
524 | + $val = $this->expandEntities($val); |
|
525 | + if ($use == 'literal') { |
|
526 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
527 | + } else { |
|
528 | + $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>"; |
|
529 | + } |
|
530 | + break; |
|
531 | + case is_object($val): |
|
532 | + $this->debug("serialize_val: serialize object"); |
|
533 | + if (get_class($val) == 'soapval') { |
|
534 | + $this->debug("serialize_val: serialize soapval object"); |
|
535 | + $pXml = $val->serialize($use); |
|
536 | + $this->appendDebug($val->getDebug()); |
|
537 | + $val->clearDebug(); |
|
538 | + } else { |
|
539 | + if (! $name) { |
|
540 | + $name = get_class($val); |
|
541 | + $this->debug("In serialize_val, used class name $name as element name"); |
|
542 | + } else { |
|
543 | + $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val)); |
|
544 | + } |
|
545 | + foreach(get_object_vars($val) as $k => $v){ |
|
546 | + $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); |
|
547 | + } |
|
548 | + } |
|
549 | + if(isset($type) && isset($type_prefix)){ |
|
550 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
551 | + } else { |
|
552 | + $type_str = ''; |
|
553 | + } |
|
554 | + if ($use == 'literal') { |
|
555 | + $xml .= "<$name$xmlns$atts>$pXml</$name>"; |
|
556 | + } else { |
|
557 | + $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>"; |
|
558 | + } |
|
559 | + break; |
|
560 | + break; |
|
561 | + case (is_array($val) || $type): |
|
562 | + // detect if struct or array |
|
563 | + $valueType = $this->isArraySimpleOrStruct($val); |
|
564 | 564 | if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ |
565 | - $this->debug("serialize_val: serialize array"); |
|
566 | - $i = 0; |
|
567 | - if(is_array($val) && count($val)> 0){ |
|
568 | - foreach($val as $v){ |
|
569 | - if(is_object($v) && get_class($v) == 'soapval'){ |
|
570 | - $tt_ns = $v->type_ns; |
|
571 | - $tt = $v->type; |
|
572 | - } elseif (is_array($v)) { |
|
573 | - $tt = $this->isArraySimpleOrStruct($v); |
|
574 | - } else { |
|
575 | - $tt = gettype($v); |
|
576 | - } |
|
577 | - $array_types[$tt] = 1; |
|
578 | - // TODO: for literal, the name should be $name |
|
579 | - $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
|
580 | - ++$i; |
|
581 | - } |
|
582 | - if(count($array_types) > 1){ |
|
583 | - $array_typename = 'xsd:anyType'; |
|
584 | - } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { |
|
585 | - if ($tt == 'integer') { |
|
586 | - $tt = 'int'; |
|
587 | - } |
|
588 | - $array_typename = 'xsd:'.$tt; |
|
589 | - } elseif(isset($tt) && $tt == 'arraySimple'){ |
|
590 | - $array_typename = 'SOAP-ENC:Array'; |
|
591 | - } elseif(isset($tt) && $tt == 'arrayStruct'){ |
|
592 | - $array_typename = 'unnamed_struct_use_soapval'; |
|
593 | - } else { |
|
594 | - // if type is prefixed, create type prefix |
|
595 | - if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){ |
|
596 | - $array_typename = 'xsd:' . $tt; |
|
597 | - } elseif ($tt_ns) { |
|
598 | - $tt_prefix = 'ns' . rand(1000, 9999); |
|
599 | - $array_typename = "$tt_prefix:$tt"; |
|
600 | - $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; |
|
601 | - } else { |
|
602 | - $array_typename = $tt; |
|
603 | - } |
|
604 | - } |
|
605 | - $array_type = $i; |
|
606 | - if ($use == 'literal') { |
|
607 | - $type_str = ''; |
|
608 | - } else if (isset($type) && isset($type_prefix)) { |
|
609 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
610 | - } else { |
|
611 | - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\""; |
|
612 | - } |
|
613 | - // empty array |
|
614 | - } else { |
|
615 | - if ($use == 'literal') { |
|
616 | - $type_str = ''; |
|
617 | - } else if (isset($type) && isset($type_prefix)) { |
|
618 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
619 | - } else { |
|
620 | - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; |
|
621 | - } |
|
622 | - } |
|
623 | - // TODO: for array in literal, there is no wrapper here |
|
624 | - $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>"; |
|
625 | - } else { |
|
626 | - // got a struct |
|
627 | - $this->debug("serialize_val: serialize struct"); |
|
628 | - if(isset($type) && isset($type_prefix)){ |
|
629 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
630 | - } else { |
|
631 | - $type_str = ''; |
|
632 | - } |
|
633 | - if ($use == 'literal') { |
|
634 | - $xml .= "<$name$xmlns$atts>"; |
|
635 | - } else { |
|
636 | - $xml .= "<$name$xmlns$type_str$atts>"; |
|
637 | - } |
|
638 | - foreach($val as $k => $v){ |
|
639 | - // Apache Map |
|
640 | - if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') { |
|
641 | - $xml .= '<item>'; |
|
642 | - $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
643 | - $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
644 | - $xml .= '</item>'; |
|
645 | - } else { |
|
646 | - $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
647 | - } |
|
648 | - } |
|
649 | - $xml .= "</$name>"; |
|
650 | - } |
|
651 | - break; |
|
652 | - default: |
|
653 | - $this->debug("serialize_val: serialize unknown"); |
|
654 | - $xml .= 'not detected, got '.gettype($val).' for '.$val; |
|
655 | - break; |
|
656 | - } |
|
657 | - $this->debug("serialize_val returning $xml"); |
|
658 | - return $xml; |
|
659 | - } |
|
660 | - |
|
661 | - /** |
|
662 | - * serializes a message |
|
663 | - * |
|
664 | - * @param string $body the XML of the SOAP body |
|
665 | - * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
666 | - * @param array $namespaces optional the namespaces used in generating the body and headers |
|
667 | - * @param string $style optional (rpc|document) |
|
668 | - * @param string $use optional (encoded|literal) |
|
669 | - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
670 | - * @return string the message |
|
671 | - * @access public |
|
672 | - */ |
|
565 | + $this->debug("serialize_val: serialize array"); |
|
566 | + $i = 0; |
|
567 | + if(is_array($val) && count($val)> 0){ |
|
568 | + foreach($val as $v){ |
|
569 | + if(is_object($v) && get_class($v) == 'soapval'){ |
|
570 | + $tt_ns = $v->type_ns; |
|
571 | + $tt = $v->type; |
|
572 | + } elseif (is_array($v)) { |
|
573 | + $tt = $this->isArraySimpleOrStruct($v); |
|
574 | + } else { |
|
575 | + $tt = gettype($v); |
|
576 | + } |
|
577 | + $array_types[$tt] = 1; |
|
578 | + // TODO: for literal, the name should be $name |
|
579 | + $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
|
580 | + ++$i; |
|
581 | + } |
|
582 | + if(count($array_types) > 1){ |
|
583 | + $array_typename = 'xsd:anyType'; |
|
584 | + } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { |
|
585 | + if ($tt == 'integer') { |
|
586 | + $tt = 'int'; |
|
587 | + } |
|
588 | + $array_typename = 'xsd:'.$tt; |
|
589 | + } elseif(isset($tt) && $tt == 'arraySimple'){ |
|
590 | + $array_typename = 'SOAP-ENC:Array'; |
|
591 | + } elseif(isset($tt) && $tt == 'arrayStruct'){ |
|
592 | + $array_typename = 'unnamed_struct_use_soapval'; |
|
593 | + } else { |
|
594 | + // if type is prefixed, create type prefix |
|
595 | + if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){ |
|
596 | + $array_typename = 'xsd:' . $tt; |
|
597 | + } elseif ($tt_ns) { |
|
598 | + $tt_prefix = 'ns' . rand(1000, 9999); |
|
599 | + $array_typename = "$tt_prefix:$tt"; |
|
600 | + $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; |
|
601 | + } else { |
|
602 | + $array_typename = $tt; |
|
603 | + } |
|
604 | + } |
|
605 | + $array_type = $i; |
|
606 | + if ($use == 'literal') { |
|
607 | + $type_str = ''; |
|
608 | + } else if (isset($type) && isset($type_prefix)) { |
|
609 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
610 | + } else { |
|
611 | + $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\""; |
|
612 | + } |
|
613 | + // empty array |
|
614 | + } else { |
|
615 | + if ($use == 'literal') { |
|
616 | + $type_str = ''; |
|
617 | + } else if (isset($type) && isset($type_prefix)) { |
|
618 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
619 | + } else { |
|
620 | + $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; |
|
621 | + } |
|
622 | + } |
|
623 | + // TODO: for array in literal, there is no wrapper here |
|
624 | + $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>"; |
|
625 | + } else { |
|
626 | + // got a struct |
|
627 | + $this->debug("serialize_val: serialize struct"); |
|
628 | + if(isset($type) && isset($type_prefix)){ |
|
629 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
630 | + } else { |
|
631 | + $type_str = ''; |
|
632 | + } |
|
633 | + if ($use == 'literal') { |
|
634 | + $xml .= "<$name$xmlns$atts>"; |
|
635 | + } else { |
|
636 | + $xml .= "<$name$xmlns$type_str$atts>"; |
|
637 | + } |
|
638 | + foreach($val as $k => $v){ |
|
639 | + // Apache Map |
|
640 | + if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') { |
|
641 | + $xml .= '<item>'; |
|
642 | + $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
643 | + $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
644 | + $xml .= '</item>'; |
|
645 | + } else { |
|
646 | + $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
647 | + } |
|
648 | + } |
|
649 | + $xml .= "</$name>"; |
|
650 | + } |
|
651 | + break; |
|
652 | + default: |
|
653 | + $this->debug("serialize_val: serialize unknown"); |
|
654 | + $xml .= 'not detected, got '.gettype($val).' for '.$val; |
|
655 | + break; |
|
656 | + } |
|
657 | + $this->debug("serialize_val returning $xml"); |
|
658 | + return $xml; |
|
659 | + } |
|
660 | + |
|
661 | + /** |
|
662 | + * serializes a message |
|
663 | + * |
|
664 | + * @param string $body the XML of the SOAP body |
|
665 | + * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
666 | + * @param array $namespaces optional the namespaces used in generating the body and headers |
|
667 | + * @param string $style optional (rpc|document) |
|
668 | + * @param string $use optional (encoded|literal) |
|
669 | + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
670 | + * @return string the message |
|
671 | + * @access public |
|
672 | + */ |
|
673 | 673 | function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){ |
674 | 674 | // TODO: add an option to automatically run utf8_encode on $body and $headers |
675 | 675 | // if $this->soap_defencoding is UTF-8. Not doing this automatically allows |
676 | 676 | // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1 |
677 | 677 | |
678 | - $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); |
|
679 | - $this->debug("headers:"); |
|
680 | - $this->appendDebug($this->varDump($headers)); |
|
681 | - $this->debug("namespaces:"); |
|
682 | - $this->appendDebug($this->varDump($namespaces)); |
|
678 | + $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); |
|
679 | + $this->debug("headers:"); |
|
680 | + $this->appendDebug($this->varDump($headers)); |
|
681 | + $this->debug("namespaces:"); |
|
682 | + $this->appendDebug($this->varDump($namespaces)); |
|
683 | 683 | |
684 | - // serialize namespaces |
|
684 | + // serialize namespaces |
|
685 | 685 | $ns_string = ''; |
686 | - foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ |
|
687 | - $ns_string .= " xmlns:$k=\"$v\""; |
|
688 | - } |
|
689 | - if($encodingStyle) { |
|
690 | - $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; |
|
691 | - } |
|
692 | - |
|
693 | - // serialize headers |
|
694 | - if($headers){ |
|
695 | - if (is_array($headers)) { |
|
696 | - $xml = ''; |
|
697 | - foreach ($headers as $k => $v) { |
|
698 | - if (is_object($v) && get_class($v) == 'soapval') { |
|
699 | - $xml .= $this->serialize_val($v, false, false, false, false, false, $use); |
|
700 | - } else { |
|
701 | - $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
702 | - } |
|
703 | - } |
|
704 | - $headers = $xml; |
|
705 | - $this->debug("In serializeEnvelope, serialized array of headers to $headers"); |
|
706 | - } |
|
707 | - $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>"; |
|
708 | - } |
|
709 | - // serialize envelope |
|
710 | - return |
|
711 | - '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">". |
|
712 | - '<SOAP-ENV:Envelope'.$ns_string.">". |
|
713 | - $headers. |
|
714 | - "<SOAP-ENV:Body>". |
|
715 | - $body. |
|
716 | - "</SOAP-ENV:Body>". |
|
717 | - "</SOAP-ENV:Envelope>"; |
|
718 | - } |
|
719 | - |
|
720 | - /** |
|
721 | - * formats a string to be inserted into an HTML stream |
|
722 | - * |
|
723 | - * @param string $str The string to format |
|
724 | - * @return string The formatted string |
|
725 | - * @access public |
|
726 | - * @deprecated |
|
727 | - */ |
|
686 | + foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ |
|
687 | + $ns_string .= " xmlns:$k=\"$v\""; |
|
688 | + } |
|
689 | + if($encodingStyle) { |
|
690 | + $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; |
|
691 | + } |
|
692 | + |
|
693 | + // serialize headers |
|
694 | + if($headers){ |
|
695 | + if (is_array($headers)) { |
|
696 | + $xml = ''; |
|
697 | + foreach ($headers as $k => $v) { |
|
698 | + if (is_object($v) && get_class($v) == 'soapval') { |
|
699 | + $xml .= $this->serialize_val($v, false, false, false, false, false, $use); |
|
700 | + } else { |
|
701 | + $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
702 | + } |
|
703 | + } |
|
704 | + $headers = $xml; |
|
705 | + $this->debug("In serializeEnvelope, serialized array of headers to $headers"); |
|
706 | + } |
|
707 | + $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>"; |
|
708 | + } |
|
709 | + // serialize envelope |
|
710 | + return |
|
711 | + '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">". |
|
712 | + '<SOAP-ENV:Envelope'.$ns_string.">". |
|
713 | + $headers. |
|
714 | + "<SOAP-ENV:Body>". |
|
715 | + $body. |
|
716 | + "</SOAP-ENV:Body>". |
|
717 | + "</SOAP-ENV:Envelope>"; |
|
718 | + } |
|
719 | + |
|
720 | + /** |
|
721 | + * formats a string to be inserted into an HTML stream |
|
722 | + * |
|
723 | + * @param string $str The string to format |
|
724 | + * @return string The formatted string |
|
725 | + * @access public |
|
726 | + * @deprecated |
|
727 | + */ |
|
728 | 728 | function formatDump($str){ |
729 | - $str = htmlspecialchars($str); |
|
730 | - return nl2br($str); |
|
731 | - } |
|
732 | - |
|
733 | - /** |
|
734 | - * contracts (changes namespace to prefix) a qualified name |
|
735 | - * |
|
736 | - * @param string $qname qname |
|
737 | - * @return string contracted qname |
|
738 | - * @access private |
|
739 | - */ |
|
740 | - function contractQname($qname){ |
|
741 | - // get element namespace |
|
742 | - //$this->xdebug("Contract $qname"); |
|
743 | - if (strrpos($qname, ':')) { |
|
744 | - // get unqualified name |
|
745 | - $name = substr($qname, strrpos($qname, ':') + 1); |
|
746 | - // get ns |
|
747 | - $ns = substr($qname, 0, strrpos($qname, ':')); |
|
748 | - $p = $this->getPrefixFromNamespace($ns); |
|
749 | - if ($p) { |
|
750 | - return $p . ':' . $name; |
|
751 | - } |
|
752 | - return $qname; |
|
753 | - } else { |
|
754 | - return $qname; |
|
755 | - } |
|
756 | - } |
|
757 | - |
|
758 | - /** |
|
759 | - * expands (changes prefix to namespace) a qualified name |
|
760 | - * |
|
761 | - * @param string $qname qname |
|
762 | - * @return string expanded qname |
|
763 | - * @access private |
|
764 | - */ |
|
765 | - function expandQname($qname){ |
|
766 | - // get element prefix |
|
767 | - if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ |
|
768 | - // get unqualified name |
|
769 | - $name = substr(strstr($qname,':'),1); |
|
770 | - // get ns prefix |
|
771 | - $prefix = substr($qname,0,strpos($qname,':')); |
|
772 | - if(isset($this->namespaces[$prefix])){ |
|
773 | - return $this->namespaces[$prefix].':'.$name; |
|
774 | - } else { |
|
775 | - return $qname; |
|
776 | - } |
|
777 | - } else { |
|
778 | - return $qname; |
|
779 | - } |
|
780 | - } |
|
781 | - |
|
782 | - /** |
|
783 | - * returns the local part of a prefixed string |
|
784 | - * returns the original string, if not prefixed |
|
785 | - * |
|
786 | - * @param string $str The prefixed string |
|
787 | - * @return string The local part |
|
788 | - * @access public |
|
789 | - */ |
|
790 | - function getLocalPart($str){ |
|
791 | - if($sstr = strrchr($str,':')){ |
|
792 | - // get unqualified name |
|
793 | - return substr( $sstr, 1 ); |
|
794 | - } else { |
|
795 | - return $str; |
|
796 | - } |
|
797 | - } |
|
798 | - |
|
799 | - /** |
|
800 | - * returns the prefix part of a prefixed string |
|
801 | - * returns false, if not prefixed |
|
802 | - * |
|
803 | - * @param string $str The prefixed string |
|
804 | - * @return mixed The prefix or false if there is no prefix |
|
805 | - * @access public |
|
806 | - */ |
|
807 | - function getPrefix($str){ |
|
808 | - if($pos = strrpos($str,':')){ |
|
809 | - // get prefix |
|
810 | - return substr($str,0,$pos); |
|
811 | - } |
|
812 | - return false; |
|
813 | - } |
|
814 | - |
|
815 | - /** |
|
816 | - * pass it a prefix, it returns a namespace |
|
817 | - * |
|
818 | - * @param string $prefix The prefix |
|
819 | - * @return mixed The namespace, false if no namespace has the specified prefix |
|
820 | - * @access public |
|
821 | - */ |
|
822 | - function getNamespaceFromPrefix($prefix){ |
|
823 | - if (isset($this->namespaces[$prefix])) { |
|
824 | - return $this->namespaces[$prefix]; |
|
825 | - } |
|
826 | - //$this->setError("No namespace registered for prefix '$prefix'"); |
|
827 | - return false; |
|
828 | - } |
|
829 | - |
|
830 | - /** |
|
831 | - * returns the prefix for a given namespace (or prefix) |
|
832 | - * or false if no prefixes registered for the given namespace |
|
833 | - * |
|
834 | - * @param string $ns The namespace |
|
835 | - * @return mixed The prefix, false if the namespace has no prefixes |
|
836 | - * @access public |
|
837 | - */ |
|
838 | - function getPrefixFromNamespace($ns) { |
|
839 | - foreach ($this->namespaces as $p => $n) { |
|
840 | - if ($ns == $n || $ns == $p) { |
|
841 | - $this->usedNamespaces[$p] = $n; |
|
842 | - return $p; |
|
843 | - } |
|
844 | - } |
|
845 | - return false; |
|
846 | - } |
|
847 | - |
|
848 | - /** |
|
849 | - * returns the time in ODBC canonical form with microseconds |
|
850 | - * |
|
851 | - * @return string The time in ODBC canonical form with microseconds |
|
852 | - * @access public |
|
853 | - */ |
|
854 | - function getmicrotime() { |
|
855 | - if (function_exists('gettimeofday')) { |
|
856 | - $tod = gettimeofday(); |
|
857 | - $sec = $tod['sec']; |
|
858 | - $usec = $tod['usec']; |
|
859 | - } else { |
|
860 | - $sec = time(); |
|
861 | - $usec = 0; |
|
862 | - } |
|
863 | - return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec); |
|
864 | - } |
|
865 | - |
|
866 | - /** |
|
867 | - * Returns a string with the output of var_dump |
|
868 | - * |
|
869 | - * @param mixed $data The variable to var_dump |
|
870 | - * @return string The output of var_dump |
|
871 | - * @access public |
|
872 | - */ |
|
729 | + $str = htmlspecialchars($str); |
|
730 | + return nl2br($str); |
|
731 | + } |
|
732 | + |
|
733 | + /** |
|
734 | + * contracts (changes namespace to prefix) a qualified name |
|
735 | + * |
|
736 | + * @param string $qname qname |
|
737 | + * @return string contracted qname |
|
738 | + * @access private |
|
739 | + */ |
|
740 | + function contractQname($qname){ |
|
741 | + // get element namespace |
|
742 | + //$this->xdebug("Contract $qname"); |
|
743 | + if (strrpos($qname, ':')) { |
|
744 | + // get unqualified name |
|
745 | + $name = substr($qname, strrpos($qname, ':') + 1); |
|
746 | + // get ns |
|
747 | + $ns = substr($qname, 0, strrpos($qname, ':')); |
|
748 | + $p = $this->getPrefixFromNamespace($ns); |
|
749 | + if ($p) { |
|
750 | + return $p . ':' . $name; |
|
751 | + } |
|
752 | + return $qname; |
|
753 | + } else { |
|
754 | + return $qname; |
|
755 | + } |
|
756 | + } |
|
757 | + |
|
758 | + /** |
|
759 | + * expands (changes prefix to namespace) a qualified name |
|
760 | + * |
|
761 | + * @param string $qname qname |
|
762 | + * @return string expanded qname |
|
763 | + * @access private |
|
764 | + */ |
|
765 | + function expandQname($qname){ |
|
766 | + // get element prefix |
|
767 | + if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ |
|
768 | + // get unqualified name |
|
769 | + $name = substr(strstr($qname,':'),1); |
|
770 | + // get ns prefix |
|
771 | + $prefix = substr($qname,0,strpos($qname,':')); |
|
772 | + if(isset($this->namespaces[$prefix])){ |
|
773 | + return $this->namespaces[$prefix].':'.$name; |
|
774 | + } else { |
|
775 | + return $qname; |
|
776 | + } |
|
777 | + } else { |
|
778 | + return $qname; |
|
779 | + } |
|
780 | + } |
|
781 | + |
|
782 | + /** |
|
783 | + * returns the local part of a prefixed string |
|
784 | + * returns the original string, if not prefixed |
|
785 | + * |
|
786 | + * @param string $str The prefixed string |
|
787 | + * @return string The local part |
|
788 | + * @access public |
|
789 | + */ |
|
790 | + function getLocalPart($str){ |
|
791 | + if($sstr = strrchr($str,':')){ |
|
792 | + // get unqualified name |
|
793 | + return substr( $sstr, 1 ); |
|
794 | + } else { |
|
795 | + return $str; |
|
796 | + } |
|
797 | + } |
|
798 | + |
|
799 | + /** |
|
800 | + * returns the prefix part of a prefixed string |
|
801 | + * returns false, if not prefixed |
|
802 | + * |
|
803 | + * @param string $str The prefixed string |
|
804 | + * @return mixed The prefix or false if there is no prefix |
|
805 | + * @access public |
|
806 | + */ |
|
807 | + function getPrefix($str){ |
|
808 | + if($pos = strrpos($str,':')){ |
|
809 | + // get prefix |
|
810 | + return substr($str,0,$pos); |
|
811 | + } |
|
812 | + return false; |
|
813 | + } |
|
814 | + |
|
815 | + /** |
|
816 | + * pass it a prefix, it returns a namespace |
|
817 | + * |
|
818 | + * @param string $prefix The prefix |
|
819 | + * @return mixed The namespace, false if no namespace has the specified prefix |
|
820 | + * @access public |
|
821 | + */ |
|
822 | + function getNamespaceFromPrefix($prefix){ |
|
823 | + if (isset($this->namespaces[$prefix])) { |
|
824 | + return $this->namespaces[$prefix]; |
|
825 | + } |
|
826 | + //$this->setError("No namespace registered for prefix '$prefix'"); |
|
827 | + return false; |
|
828 | + } |
|
829 | + |
|
830 | + /** |
|
831 | + * returns the prefix for a given namespace (or prefix) |
|
832 | + * or false if no prefixes registered for the given namespace |
|
833 | + * |
|
834 | + * @param string $ns The namespace |
|
835 | + * @return mixed The prefix, false if the namespace has no prefixes |
|
836 | + * @access public |
|
837 | + */ |
|
838 | + function getPrefixFromNamespace($ns) { |
|
839 | + foreach ($this->namespaces as $p => $n) { |
|
840 | + if ($ns == $n || $ns == $p) { |
|
841 | + $this->usedNamespaces[$p] = $n; |
|
842 | + return $p; |
|
843 | + } |
|
844 | + } |
|
845 | + return false; |
|
846 | + } |
|
847 | + |
|
848 | + /** |
|
849 | + * returns the time in ODBC canonical form with microseconds |
|
850 | + * |
|
851 | + * @return string The time in ODBC canonical form with microseconds |
|
852 | + * @access public |
|
853 | + */ |
|
854 | + function getmicrotime() { |
|
855 | + if (function_exists('gettimeofday')) { |
|
856 | + $tod = gettimeofday(); |
|
857 | + $sec = $tod['sec']; |
|
858 | + $usec = $tod['usec']; |
|
859 | + } else { |
|
860 | + $sec = time(); |
|
861 | + $usec = 0; |
|
862 | + } |
|
863 | + return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec); |
|
864 | + } |
|
865 | + |
|
866 | + /** |
|
867 | + * Returns a string with the output of var_dump |
|
868 | + * |
|
869 | + * @param mixed $data The variable to var_dump |
|
870 | + * @return string The output of var_dump |
|
871 | + * @access public |
|
872 | + */ |
|
873 | 873 | function varDump($data) { |
874 | - ob_start(); |
|
875 | - var_dump($data); |
|
876 | - $ret_val = ob_get_contents(); |
|
877 | - ob_end_clean(); |
|
878 | - return $ret_val; |
|
879 | - } |
|
880 | - |
|
881 | - /** |
|
882 | - * represents the object as a string |
|
883 | - * |
|
884 | - * @return string |
|
885 | - * @access public |
|
886 | - */ |
|
887 | - function __toString() { |
|
888 | - return $this->varDump($this); |
|
889 | - } |
|
874 | + ob_start(); |
|
875 | + var_dump($data); |
|
876 | + $ret_val = ob_get_contents(); |
|
877 | + ob_end_clean(); |
|
878 | + return $ret_val; |
|
879 | + } |
|
880 | + |
|
881 | + /** |
|
882 | + * represents the object as a string |
|
883 | + * |
|
884 | + * @return string |
|
885 | + * @access public |
|
886 | + */ |
|
887 | + function __toString() { |
|
888 | + return $this->varDump($this); |
|
889 | + } |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | // XML Schema Datatype Helper Functions |
@@ -902,35 +902,35 @@ discard block |
||
902 | 902 | * @access public |
903 | 903 | */ |
904 | 904 | function timestamp_to_iso8601($timestamp,$utc=true){ |
905 | - $datestr = date('Y-m-d\TH:i:sO',$timestamp); |
|
906 | - $pos = strrpos($datestr, "+"); |
|
907 | - if ($pos === FALSE) { |
|
908 | - $pos = strrpos($datestr, "-"); |
|
909 | - } |
|
910 | - if ($pos !== FALSE) { |
|
911 | - if (strlen($datestr) == $pos + 5) { |
|
912 | - $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); |
|
913 | - } |
|
914 | - } |
|
915 | - if($utc){ |
|
916 | - $pattern = '/'. |
|
917 | - '([0-9]{4})-'. // centuries & years CCYY- |
|
918 | - '([0-9]{2})-'. // months MM- |
|
919 | - '([0-9]{2})'. // days DD |
|
920 | - 'T'. // separator T |
|
921 | - '([0-9]{2}):'. // hours hh: |
|
922 | - '([0-9]{2}):'. // minutes mm: |
|
923 | - '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... |
|
924 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
925 | - '/'; |
|
926 | - |
|
927 | - if(preg_match($pattern,$datestr,$regs)){ |
|
928 | - return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); |
|
929 | - } |
|
930 | - return false; |
|
931 | - } else { |
|
932 | - return $datestr; |
|
933 | - } |
|
905 | + $datestr = date('Y-m-d\TH:i:sO',$timestamp); |
|
906 | + $pos = strrpos($datestr, "+"); |
|
907 | + if ($pos === FALSE) { |
|
908 | + $pos = strrpos($datestr, "-"); |
|
909 | + } |
|
910 | + if ($pos !== FALSE) { |
|
911 | + if (strlen($datestr) == $pos + 5) { |
|
912 | + $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); |
|
913 | + } |
|
914 | + } |
|
915 | + if($utc){ |
|
916 | + $pattern = '/'. |
|
917 | + '([0-9]{4})-'. // centuries & years CCYY- |
|
918 | + '([0-9]{2})-'. // months MM- |
|
919 | + '([0-9]{2})'. // days DD |
|
920 | + 'T'. // separator T |
|
921 | + '([0-9]{2}):'. // hours hh: |
|
922 | + '([0-9]{2}):'. // minutes mm: |
|
923 | + '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... |
|
924 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
925 | + '/'; |
|
926 | + |
|
927 | + if(preg_match($pattern,$datestr,$regs)){ |
|
928 | + return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); |
|
929 | + } |
|
930 | + return false; |
|
931 | + } else { |
|
932 | + return $datestr; |
|
933 | + } |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | /** |
@@ -941,35 +941,35 @@ discard block |
||
941 | 941 | * @access public |
942 | 942 | */ |
943 | 943 | function iso8601_to_timestamp($datestr){ |
944 | - $pattern = '/'. |
|
945 | - '([0-9]{4})-'. // centuries & years CCYY- |
|
946 | - '([0-9]{2})-'. // months MM- |
|
947 | - '([0-9]{2})'. // days DD |
|
948 | - 'T'. // separator T |
|
949 | - '([0-9]{2}):'. // hours hh: |
|
950 | - '([0-9]{2}):'. // minutes mm: |
|
951 | - '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... |
|
952 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
953 | - '/'; |
|
954 | - if(preg_match($pattern,$datestr,$regs)){ |
|
955 | - // not utc |
|
956 | - if($regs[8] != 'Z'){ |
|
957 | - $op = substr($regs[8],0,1); |
|
958 | - $h = substr($regs[8],1,2); |
|
959 | - $m = substr($regs[8],strlen($regs[8])-2,2); |
|
960 | - if($op == '-'){ |
|
961 | - $regs[4] = $regs[4] + $h; |
|
962 | - $regs[5] = $regs[5] + $m; |
|
963 | - } elseif($op == '+'){ |
|
964 | - $regs[4] = $regs[4] - $h; |
|
965 | - $regs[5] = $regs[5] - $m; |
|
966 | - } |
|
967 | - } |
|
968 | - return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
|
944 | + $pattern = '/'. |
|
945 | + '([0-9]{4})-'. // centuries & years CCYY- |
|
946 | + '([0-9]{2})-'. // months MM- |
|
947 | + '([0-9]{2})'. // days DD |
|
948 | + 'T'. // separator T |
|
949 | + '([0-9]{2}):'. // hours hh: |
|
950 | + '([0-9]{2}):'. // minutes mm: |
|
951 | + '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... |
|
952 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
953 | + '/'; |
|
954 | + if(preg_match($pattern,$datestr,$regs)){ |
|
955 | + // not utc |
|
956 | + if($regs[8] != 'Z'){ |
|
957 | + $op = substr($regs[8],0,1); |
|
958 | + $h = substr($regs[8],1,2); |
|
959 | + $m = substr($regs[8],strlen($regs[8])-2,2); |
|
960 | + if($op == '-'){ |
|
961 | + $regs[4] = $regs[4] + $h; |
|
962 | + $regs[5] = $regs[5] + $m; |
|
963 | + } elseif($op == '+'){ |
|
964 | + $regs[4] = $regs[4] - $h; |
|
965 | + $regs[5] = $regs[5] - $m; |
|
966 | + } |
|
967 | + } |
|
968 | + return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
|
969 | 969 | // return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z"); |
970 | - } else { |
|
971 | - return false; |
|
972 | - } |
|
970 | + } else { |
|
971 | + return false; |
|
972 | + } |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | /** |
@@ -981,15 +981,15 @@ discard block |
||
981 | 981 | */ |
982 | 982 | function usleepWindows($usec) |
983 | 983 | { |
984 | - $start = gettimeofday(); |
|
985 | - |
|
986 | - do |
|
987 | - { |
|
988 | - $stop = gettimeofday(); |
|
989 | - $timePassed = 1000000 * ($stop['sec'] - $start['sec']) |
|
990 | - + $stop['usec'] - $start['usec']; |
|
991 | - } |
|
992 | - while ($timePassed < $usec); |
|
984 | + $start = gettimeofday(); |
|
985 | + |
|
986 | + do |
|
987 | + { |
|
988 | + $stop = gettimeofday(); |
|
989 | + $timePassed = 1000000 * ($stop['sec'] - $start['sec']) |
|
990 | + + $stop['usec'] - $start['usec']; |
|
991 | + } |
|
992 | + while ($timePassed < $usec); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 |
@@ -183,26 +183,26 @@ discard block |
||
183 | 183 | */ |
184 | 184 | var $typemap = array( |
185 | 185 | 'http://www.w3.org/2001/XMLSchema' => array( |
186 | - 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
|
187 | - 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', |
|
188 | - 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', |
|
186 | + 'string'=>'string', 'boolean'=>'boolean', 'float'=>'double', 'double'=>'double', 'decimal'=>'double', |
|
187 | + 'duration'=>'', 'dateTime'=>'string', 'time'=>'string', 'date'=>'string', 'gYearMonth'=>'', |
|
188 | + 'gYear'=>'', 'gMonthDay'=>'', 'gDay'=>'', 'gMonth'=>'', 'hexBinary'=>'string', 'base64Binary'=>'string', |
|
189 | 189 | // abstract "any" types |
190 | - 'anyType'=>'string','anySimpleType'=>'string', |
|
190 | + 'anyType'=>'string', 'anySimpleType'=>'string', |
|
191 | 191 | // derived datatypes |
192 | - 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', |
|
193 | - 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', |
|
194 | - 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', |
|
195 | - 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), |
|
192 | + 'normalizedString'=>'string', 'token'=>'string', 'language'=>'', 'NMTOKEN'=>'', 'NMTOKENS'=>'', 'Name'=>'', 'NCName'=>'', 'ID'=>'', |
|
193 | + 'IDREF'=>'', 'IDREFS'=>'', 'ENTITY'=>'', 'ENTITIES'=>'', 'integer'=>'integer', 'nonPositiveInteger'=>'integer', |
|
194 | + 'negativeInteger'=>'integer', 'long'=>'integer', 'int'=>'integer', 'short'=>'integer', 'byte'=>'integer', 'nonNegativeInteger'=>'integer', |
|
195 | + 'unsignedLong'=>'', 'unsignedInt'=>'', 'unsignedShort'=>'', 'unsignedByte'=>'', 'positiveInteger'=>''), |
|
196 | 196 | 'http://www.w3.org/2000/10/XMLSchema' => array( |
197 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
198 | - 'float'=>'double','dateTime'=>'string', |
|
199 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
197 | + 'i4'=>'', 'int'=>'integer', 'boolean'=>'boolean', 'string'=>'string', 'double'=>'double', |
|
198 | + 'float'=>'double', 'dateTime'=>'string', |
|
199 | + 'timeInstant'=>'string', 'base64Binary'=>'string', 'base64'=>'string', 'ur-type'=>'array'), |
|
200 | 200 | 'http://www.w3.org/1999/XMLSchema' => array( |
201 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
202 | - 'float'=>'double','dateTime'=>'string', |
|
203 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
201 | + 'i4'=>'', 'int'=>'integer', 'boolean'=>'boolean', 'string'=>'string', 'double'=>'double', |
|
202 | + 'float'=>'double', 'dateTime'=>'string', |
|
203 | + 'timeInstant'=>'string', 'base64Binary'=>'string', 'base64'=>'string', 'ur-type'=>'array'), |
|
204 | 204 | 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), |
205 | - 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), |
|
205 | + 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string', 'array'=>'array', 'Array'=>'array'), |
|
206 | 206 | 'http://xml.apache.org/xml-soap' => array('Map') |
207 | 207 | ); |
208 | 208 | |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | * @deprecated |
215 | 215 | * @see expandEntities |
216 | 216 | */ |
217 | - var $xmlEntities = array('quot' => '"','amp' => '&', |
|
218 | - 'lt' => '<','gt' => '>','apos' => "'"); |
|
217 | + var $xmlEntities = array('quot' => '"', 'amp' => '&', |
|
218 | + 'lt' => '<', 'gt' => '>', 'apos' => "'"); |
|
219 | 219 | |
220 | 220 | /** |
221 | 221 | * constructor |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param string $string debug data |
273 | 273 | * @access private |
274 | 274 | */ |
275 | - function debug($string){ |
|
275 | + function debug($string) { |
|
276 | 276 | if ($this->debugLevel > 0) { |
277 | 277 | $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
278 | 278 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @param string $string debug data |
285 | 285 | * @access public |
286 | 286 | */ |
287 | - function appendDebug($string){ |
|
287 | + function appendDebug($string) { |
|
288 | 288 | if ($this->debugLevel > 0) { |
289 | 289 | // it would be nice to use a memory stream here to use |
290 | 290 | // memory more efficiently |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | while (strpos($this->debug_str, '--')) { |
329 | 329 | $this->debug_str = str_replace('--', '- -', $this->debug_str); |
330 | 330 | } |
331 | - $ret = "<!--\n" . $this->debug_str . "\n-->"; |
|
331 | + $ret = "<!--\n".$this->debug_str."\n-->"; |
|
332 | 332 | return $ret; |
333 | 333 | } |
334 | 334 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @return mixed error string or false |
356 | 356 | * @access public |
357 | 357 | */ |
358 | - function getError(){ |
|
359 | - if($this->error_str != ''){ |
|
358 | + function getError() { |
|
359 | + if ($this->error_str != '') { |
|
360 | 360 | return $this->error_str; |
361 | 361 | } |
362 | 362 | return false; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @return boolean $string error string |
369 | 369 | * @access private |
370 | 370 | */ |
371 | - function setError($str){ |
|
371 | + function setError($str) { |
|
372 | 372 | $this->error_str = $str; |
373 | 373 | } |
374 | 374 | |
@@ -404,12 +404,12 @@ discard block |
||
404 | 404 | * @return string The serialized element, possibly with child elements |
405 | 405 | * @access public |
406 | 406 | */ |
407 | - function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) { |
|
407 | + function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false) { |
|
408 | 408 | $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); |
409 | - $this->appendDebug('value=' . $this->varDump($val)); |
|
410 | - $this->appendDebug('attributes=' . $this->varDump($attributes)); |
|
409 | + $this->appendDebug('value='.$this->varDump($val)); |
|
410 | + $this->appendDebug('attributes='.$this->varDump($attributes)); |
|
411 | 411 | |
412 | - if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { |
|
412 | + if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) { |
|
413 | 413 | $this->debug("serialize_val: serialize soapval"); |
414 | 414 | $xml = $val->serialize($use); |
415 | 415 | $this->appendDebug($val->getDebug()); |
@@ -419,30 +419,30 @@ discard block |
||
419 | 419 | } |
420 | 420 | // force valid name if necessary |
421 | 421 | if (is_numeric($name)) { |
422 | - $name = '__numeric_' . $name; |
|
423 | - } elseif (! $name) { |
|
422 | + $name = '__numeric_'.$name; |
|
423 | + } elseif (!$name) { |
|
424 | 424 | $name = 'noname'; |
425 | 425 | } |
426 | 426 | // if name has ns, add ns prefix to name |
427 | 427 | $xmlns = ''; |
428 | - if($name_ns){ |
|
429 | - $prefix = 'nu'.rand(1000,9999); |
|
428 | + if ($name_ns) { |
|
429 | + $prefix = 'nu'.rand(1000, 9999); |
|
430 | 430 | $name = $prefix.':'.$name; |
431 | 431 | $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
432 | 432 | } |
433 | 433 | // if type is prefixed, create type prefix |
434 | - if($type_ns != '' && $type_ns == $this->namespaces['xsd']){ |
|
434 | + if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) { |
|
435 | 435 | // need to fix this. shouldn't default to xsd if no ns specified |
436 | 436 | // w/o checking against typemap |
437 | 437 | $type_prefix = 'xsd'; |
438 | - } elseif($type_ns){ |
|
439 | - $type_prefix = 'ns'.rand(1000,9999); |
|
438 | + } elseif ($type_ns) { |
|
439 | + $type_prefix = 'ns'.rand(1000, 9999); |
|
440 | 440 | $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; |
441 | 441 | } |
442 | 442 | // serialize attributes if present |
443 | 443 | $atts = ''; |
444 | - if($attributes){ |
|
445 | - foreach($attributes as $k => $v){ |
|
444 | + if ($attributes) { |
|
445 | + foreach ($attributes as $k => $v) { |
|
446 | 446 | $atts .= " $k=\"".$this->expandEntities($v).'"'; |
447 | 447 | } |
448 | 448 | } |
@@ -466,12 +466,12 @@ discard block |
||
466 | 466 | } |
467 | 467 | } |
468 | 468 | // serialize if an xsd built-in primitive type |
469 | - if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){ |
|
469 | + if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) { |
|
470 | 470 | $this->debug("serialize_val: serialize xsd built-in primitive type"); |
471 | 471 | if (is_bool($val)) { |
472 | 472 | if ($type == 'boolean') { |
473 | 473 | $val = $val ? 'true' : 'false'; |
474 | - } elseif (! $val) { |
|
474 | + } elseif (!$val) { |
|
475 | 475 | $val = 0; |
476 | 476 | } |
477 | 477 | } else if (is_string($val)) { |
@@ -489,12 +489,12 @@ discard block |
||
489 | 489 | } |
490 | 490 | // detect type and serialize |
491 | 491 | $xml = ''; |
492 | - switch(true) { |
|
492 | + switch (true) { |
|
493 | 493 | case (is_bool($val) || $type == 'boolean'): |
494 | 494 | $this->debug("serialize_val: serialize boolean"); |
495 | 495 | if ($type == 'boolean') { |
496 | 496 | $val = $val ? 'true' : 'false'; |
497 | - } elseif (! $val) { |
|
497 | + } elseif (!$val) { |
|
498 | 498 | $val = 0; |
499 | 499 | } |
500 | 500 | if ($use == 'literal') { |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>"; |
512 | 512 | } |
513 | 513 | break; |
514 | - case (is_float($val)|| is_double($val) || $type == 'float'): |
|
514 | + case (is_float($val) || is_double($val) || $type == 'float'): |
|
515 | 515 | $this->debug("serialize_val: serialize float"); |
516 | 516 | if ($use == 'literal') { |
517 | 517 | $xml .= "<$name$xmlns$atts>$val</$name>"; |
@@ -536,17 +536,17 @@ discard block |
||
536 | 536 | $this->appendDebug($val->getDebug()); |
537 | 537 | $val->clearDebug(); |
538 | 538 | } else { |
539 | - if (! $name) { |
|
539 | + if (!$name) { |
|
540 | 540 | $name = get_class($val); |
541 | 541 | $this->debug("In serialize_val, used class name $name as element name"); |
542 | 542 | } else { |
543 | - $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val)); |
|
543 | + $this->debug("In serialize_val, do not override name $name for element name for class ".get_class($val)); |
|
544 | 544 | } |
545 | - foreach(get_object_vars($val) as $k => $v){ |
|
546 | - $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); |
|
545 | + foreach (get_object_vars($val) as $k => $v) { |
|
546 | + $pXml = isset($pXml) ? $pXml.$this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use); |
|
547 | 547 | } |
548 | 548 | } |
549 | - if(isset($type) && isset($type_prefix)){ |
|
549 | + if (isset($type) && isset($type_prefix)) { |
|
550 | 550 | $type_str = " xsi:type=\"$type_prefix:$type\""; |
551 | 551 | } else { |
552 | 552 | $type_str = ''; |
@@ -561,12 +561,12 @@ discard block |
||
561 | 561 | case (is_array($val) || $type): |
562 | 562 | // detect if struct or array |
563 | 563 | $valueType = $this->isArraySimpleOrStruct($val); |
564 | - if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ |
|
564 | + if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) { |
|
565 | 565 | $this->debug("serialize_val: serialize array"); |
566 | 566 | $i = 0; |
567 | - if(is_array($val) && count($val)> 0){ |
|
568 | - foreach($val as $v){ |
|
569 | - if(is_object($v) && get_class($v) == 'soapval'){ |
|
567 | + if (is_array($val) && count($val) > 0) { |
|
568 | + foreach ($val as $v) { |
|
569 | + if (is_object($v) && get_class($v) == 'soapval') { |
|
570 | 570 | $tt_ns = $v->type_ns; |
571 | 571 | $tt = $v->type; |
572 | 572 | } elseif (is_array($v)) { |
@@ -576,26 +576,26 @@ discard block |
||
576 | 576 | } |
577 | 577 | $array_types[$tt] = 1; |
578 | 578 | // TODO: for literal, the name should be $name |
579 | - $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
|
579 | + $xml .= $this->serialize_val($v, 'item', false, false, false, false, $use); |
|
580 | 580 | ++$i; |
581 | 581 | } |
582 | - if(count($array_types) > 1){ |
|
582 | + if (count($array_types) > 1) { |
|
583 | 583 | $array_typename = 'xsd:anyType'; |
584 | - } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { |
|
584 | + } elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { |
|
585 | 585 | if ($tt == 'integer') { |
586 | 586 | $tt = 'int'; |
587 | 587 | } |
588 | 588 | $array_typename = 'xsd:'.$tt; |
589 | - } elseif(isset($tt) && $tt == 'arraySimple'){ |
|
589 | + } elseif (isset($tt) && $tt == 'arraySimple') { |
|
590 | 590 | $array_typename = 'SOAP-ENC:Array'; |
591 | - } elseif(isset($tt) && $tt == 'arrayStruct'){ |
|
591 | + } elseif (isset($tt) && $tt == 'arrayStruct') { |
|
592 | 592 | $array_typename = 'unnamed_struct_use_soapval'; |
593 | 593 | } else { |
594 | 594 | // if type is prefixed, create type prefix |
595 | - if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){ |
|
596 | - $array_typename = 'xsd:' . $tt; |
|
595 | + if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) { |
|
596 | + $array_typename = 'xsd:'.$tt; |
|
597 | 597 | } elseif ($tt_ns) { |
598 | - $tt_prefix = 'ns' . rand(1000, 9999); |
|
598 | + $tt_prefix = 'ns'.rand(1000, 9999); |
|
599 | 599 | $array_typename = "$tt_prefix:$tt"; |
600 | 600 | $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; |
601 | 601 | } else { |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | } else { |
626 | 626 | // got a struct |
627 | 627 | $this->debug("serialize_val: serialize struct"); |
628 | - if(isset($type) && isset($type_prefix)){ |
|
628 | + if (isset($type) && isset($type_prefix)) { |
|
629 | 629 | $type_str = " xsi:type=\"$type_prefix:$type\""; |
630 | 630 | } else { |
631 | 631 | $type_str = ''; |
@@ -635,15 +635,15 @@ discard block |
||
635 | 635 | } else { |
636 | 636 | $xml .= "<$name$xmlns$type_str$atts>"; |
637 | 637 | } |
638 | - foreach($val as $k => $v){ |
|
638 | + foreach ($val as $k => $v) { |
|
639 | 639 | // Apache Map |
640 | 640 | if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') { |
641 | 641 | $xml .= '<item>'; |
642 | - $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
643 | - $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
642 | + $xml .= $this->serialize_val($k, 'key', false, false, false, false, $use); |
|
643 | + $xml .= $this->serialize_val($v, 'value', false, false, false, false, $use); |
|
644 | 644 | $xml .= '</item>'; |
645 | 645 | } else { |
646 | - $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
646 | + $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | $xml .= "</$name>"; |
@@ -670,12 +670,12 @@ discard block |
||
670 | 670 | * @return string the message |
671 | 671 | * @access public |
672 | 672 | */ |
673 | - function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){ |
|
673 | + function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/') { |
|
674 | 674 | // TODO: add an option to automatically run utf8_encode on $body and $headers |
675 | 675 | // if $this->soap_defencoding is UTF-8. Not doing this automatically allows |
676 | 676 | // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1 |
677 | 677 | |
678 | - $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); |
|
678 | + $this->debug("In serializeEnvelope length=".strlen($body)." body (max 1000 characters)=".substr($body, 0, 1000)." style=$style use=$use encodingStyle=$encodingStyle"); |
|
679 | 679 | $this->debug("headers:"); |
680 | 680 | $this->appendDebug($this->varDump($headers)); |
681 | 681 | $this->debug("namespaces:"); |
@@ -683,15 +683,15 @@ discard block |
||
683 | 683 | |
684 | 684 | // serialize namespaces |
685 | 685 | $ns_string = ''; |
686 | - foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ |
|
686 | + foreach (array_merge($this->namespaces, $namespaces) as $k => $v) { |
|
687 | 687 | $ns_string .= " xmlns:$k=\"$v\""; |
688 | 688 | } |
689 | - if($encodingStyle) { |
|
689 | + if ($encodingStyle) { |
|
690 | 690 | $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; |
691 | 691 | } |
692 | 692 | |
693 | 693 | // serialize headers |
694 | - if($headers){ |
|
694 | + if ($headers) { |
|
695 | 695 | if (is_array($headers)) { |
696 | 696 | $xml = ''; |
697 | 697 | foreach ($headers as $k => $v) { |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | } |
709 | 709 | // serialize envelope |
710 | 710 | return |
711 | - '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">". |
|
711 | + '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?'.">". |
|
712 | 712 | '<SOAP-ENV:Envelope'.$ns_string.">". |
713 | 713 | $headers. |
714 | 714 | "<SOAP-ENV:Body>". |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | * @access public |
726 | 726 | * @deprecated |
727 | 727 | */ |
728 | - function formatDump($str){ |
|
728 | + function formatDump($str) { |
|
729 | 729 | $str = htmlspecialchars($str); |
730 | 730 | return nl2br($str); |
731 | 731 | } |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | * @return string contracted qname |
738 | 738 | * @access private |
739 | 739 | */ |
740 | - function contractQname($qname){ |
|
740 | + function contractQname($qname) { |
|
741 | 741 | // get element namespace |
742 | 742 | //$this->xdebug("Contract $qname"); |
743 | 743 | if (strrpos($qname, ':')) { |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | $ns = substr($qname, 0, strrpos($qname, ':')); |
748 | 748 | $p = $this->getPrefixFromNamespace($ns); |
749 | 749 | if ($p) { |
750 | - return $p . ':' . $name; |
|
750 | + return $p.':'.$name; |
|
751 | 751 | } |
752 | 752 | return $qname; |
753 | 753 | } else { |
@@ -762,14 +762,14 @@ discard block |
||
762 | 762 | * @return string expanded qname |
763 | 763 | * @access private |
764 | 764 | */ |
765 | - function expandQname($qname){ |
|
765 | + function expandQname($qname) { |
|
766 | 766 | // get element prefix |
767 | - if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ |
|
767 | + if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) { |
|
768 | 768 | // get unqualified name |
769 | - $name = substr(strstr($qname,':'),1); |
|
769 | + $name = substr(strstr($qname, ':'), 1); |
|
770 | 770 | // get ns prefix |
771 | - $prefix = substr($qname,0,strpos($qname,':')); |
|
772 | - if(isset($this->namespaces[$prefix])){ |
|
771 | + $prefix = substr($qname, 0, strpos($qname, ':')); |
|
772 | + if (isset($this->namespaces[$prefix])) { |
|
773 | 773 | return $this->namespaces[$prefix].':'.$name; |
774 | 774 | } else { |
775 | 775 | return $qname; |
@@ -787,10 +787,10 @@ discard block |
||
787 | 787 | * @return string The local part |
788 | 788 | * @access public |
789 | 789 | */ |
790 | - function getLocalPart($str){ |
|
791 | - if($sstr = strrchr($str,':')){ |
|
790 | + function getLocalPart($str) { |
|
791 | + if ($sstr = strrchr($str, ':')) { |
|
792 | 792 | // get unqualified name |
793 | - return substr( $sstr, 1 ); |
|
793 | + return substr($sstr, 1); |
|
794 | 794 | } else { |
795 | 795 | return $str; |
796 | 796 | } |
@@ -804,10 +804,10 @@ discard block |
||
804 | 804 | * @return mixed The prefix or false if there is no prefix |
805 | 805 | * @access public |
806 | 806 | */ |
807 | - function getPrefix($str){ |
|
808 | - if($pos = strrpos($str,':')){ |
|
807 | + function getPrefix($str) { |
|
808 | + if ($pos = strrpos($str, ':')) { |
|
809 | 809 | // get prefix |
810 | - return substr($str,0,$pos); |
|
810 | + return substr($str, 0, $pos); |
|
811 | 811 | } |
812 | 812 | return false; |
813 | 813 | } |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | * @return mixed The namespace, false if no namespace has the specified prefix |
820 | 820 | * @access public |
821 | 821 | */ |
822 | - function getNamespaceFromPrefix($prefix){ |
|
822 | + function getNamespaceFromPrefix($prefix) { |
|
823 | 823 | if (isset($this->namespaces[$prefix])) { |
824 | 824 | return $this->namespaces[$prefix]; |
825 | 825 | } |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | $sec = time(); |
861 | 861 | $usec = 0; |
862 | 862 | } |
863 | - return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec); |
|
863 | + return strftime('%Y-%m-%d %H:%M:%S', $sec).'.'.sprintf('%06d', $usec); |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | /** |
@@ -901,31 +901,31 @@ discard block |
||
901 | 901 | * @return mixed ISO 8601 date string or false |
902 | 902 | * @access public |
903 | 903 | */ |
904 | -function timestamp_to_iso8601($timestamp,$utc=true){ |
|
905 | - $datestr = date('Y-m-d\TH:i:sO',$timestamp); |
|
904 | +function timestamp_to_iso8601($timestamp, $utc = true) { |
|
905 | + $datestr = date('Y-m-d\TH:i:sO', $timestamp); |
|
906 | 906 | $pos = strrpos($datestr, "+"); |
907 | 907 | if ($pos === FALSE) { |
908 | 908 | $pos = strrpos($datestr, "-"); |
909 | 909 | } |
910 | 910 | if ($pos !== FALSE) { |
911 | 911 | if (strlen($datestr) == $pos + 5) { |
912 | - $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); |
|
912 | + $datestr = substr($datestr, 0, $pos + 3).':'.substr($datestr, -2); |
|
913 | 913 | } |
914 | 914 | } |
915 | - if($utc){ |
|
915 | + if ($utc) { |
|
916 | 916 | $pattern = '/'. |
917 | - '([0-9]{4})-'. // centuries & years CCYY- |
|
918 | - '([0-9]{2})-'. // months MM- |
|
919 | - '([0-9]{2})'. // days DD |
|
920 | - 'T'. // separator T |
|
921 | - '([0-9]{2}):'. // hours hh: |
|
922 | - '([0-9]{2}):'. // minutes mm: |
|
923 | - '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... |
|
924 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
917 | + '([0-9]{4})-'.// centuries & years CCYY- |
|
918 | + '([0-9]{2})-'.// months MM- |
|
919 | + '([0-9]{2})'.// days DD |
|
920 | + 'T'.// separator T |
|
921 | + '([0-9]{2}):'.// hours hh: |
|
922 | + '([0-9]{2}):'.// minutes mm: |
|
923 | + '([0-9]{2})(\.[0-9]*)?'.// seconds ss.ss... |
|
924 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'.// Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
925 | 925 | '/'; |
926 | 926 | |
927 | - if(preg_match($pattern,$datestr,$regs)){ |
|
928 | - return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); |
|
927 | + if (preg_match($pattern, $datestr, $regs)) { |
|
928 | + return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', $regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6]); |
|
929 | 929 | } |
930 | 930 | return false; |
931 | 931 | } else { |
@@ -940,27 +940,27 @@ discard block |
||
940 | 940 | * @return mixed Unix timestamp (int) or false |
941 | 941 | * @access public |
942 | 942 | */ |
943 | -function iso8601_to_timestamp($datestr){ |
|
943 | +function iso8601_to_timestamp($datestr) { |
|
944 | 944 | $pattern = '/'. |
945 | - '([0-9]{4})-'. // centuries & years CCYY- |
|
946 | - '([0-9]{2})-'. // months MM- |
|
947 | - '([0-9]{2})'. // days DD |
|
948 | - 'T'. // separator T |
|
949 | - '([0-9]{2}):'. // hours hh: |
|
950 | - '([0-9]{2}):'. // minutes mm: |
|
951 | - '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... |
|
952 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
945 | + '([0-9]{4})-'.// centuries & years CCYY- |
|
946 | + '([0-9]{2})-'.// months MM- |
|
947 | + '([0-9]{2})'.// days DD |
|
948 | + 'T'.// separator T |
|
949 | + '([0-9]{2}):'.// hours hh: |
|
950 | + '([0-9]{2}):'.// minutes mm: |
|
951 | + '([0-9]{2})(\.[0-9]+)?'.// seconds ss.ss... |
|
952 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'.// Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
953 | 953 | '/'; |
954 | - if(preg_match($pattern,$datestr,$regs)){ |
|
954 | + if (preg_match($pattern, $datestr, $regs)) { |
|
955 | 955 | // not utc |
956 | - if($regs[8] != 'Z'){ |
|
957 | - $op = substr($regs[8],0,1); |
|
958 | - $h = substr($regs[8],1,2); |
|
959 | - $m = substr($regs[8],strlen($regs[8])-2,2); |
|
960 | - if($op == '-'){ |
|
956 | + if ($regs[8] != 'Z') { |
|
957 | + $op = substr($regs[8], 0, 1); |
|
958 | + $h = substr($regs[8], 1, 2); |
|
959 | + $m = substr($regs[8], strlen($regs[8]) - 2, 2); |
|
960 | + if ($op == '-') { |
|
961 | 961 | $regs[4] = $regs[4] + $h; |
962 | 962 | $regs[5] = $regs[5] + $m; |
963 | - } elseif($op == '+'){ |
|
963 | + } elseif ($op == '+') { |
|
964 | 964 | $regs[4] = $regs[4] - $h; |
965 | 965 | $regs[5] = $regs[5] - $m; |
966 | 966 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) |
44 | 44 | * @param string $faultactor only used when msg routed between multiple actors |
45 | 45 | * @param string $faultstring human readable error message |
46 | - * @param mixed $faultdetail detail, typically a string or array of string |
|
46 | + * @param string $faultdetail detail, typically a string or array of string |
|
47 | 47 | */ |
48 | 48 | function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){ |
49 | 49 | parent::nusoap_base(); |
@@ -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 = |