@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param string $url The URL of the site |
19 | 19 | * @param string $description The description of the site |
20 | 20 | * @param int $active is active or not |
21 | - * @return boolean if success |
|
21 | + * @return Doctrine\DBAL\Driver\Statement|null if success |
|
22 | 22 | */ |
23 | 23 | public static function add($url, $description, $active) |
24 | 24 | { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $url |
44 | 44 | * @param string $description The description of the site |
45 | 45 | * @param int $active is active or not |
46 | - * @return boolean if success |
|
46 | + * @return Doctrine\DBAL\Driver\Statement|null if success |
|
47 | 47 | */ |
48 | 48 | public static function update($url_id, $url, $description, $active) |
49 | 49 | { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @author Julio Montoya |
68 | 68 | * @param int $id url id |
69 | 69 | * |
70 | - * @return boolean true if success |
|
70 | + * @return Doctrine\DBAL\Driver\Statement|null true if success |
|
71 | 71 | * */ |
72 | 72 | public static function delete($id) |
73 | 73 | { |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @author Julio Montoya |
367 | 367 | * @param int user id |
368 | 368 | * @param int url id |
369 | - * @return boolean true if success |
|
369 | + * @return integer true if success |
|
370 | 370 | * */ |
371 | 371 | public static function relation_url_user_exist($user_id, $url_id) |
372 | 372 | { |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @author Julio Montoya |
385 | 385 | * @param int $courseId |
386 | 386 | * @param int $urlId |
387 | - * @return boolean true if success |
|
387 | + * @return integer true if success |
|
388 | 388 | * */ |
389 | 389 | public static function relation_url_course_exist($courseId, $urlId) |
390 | 390 | { |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @author Julio Montoya |
406 | 406 | * @param int $userGroupId |
407 | 407 | * @param int $urlId |
408 | - * @return boolean true if success |
|
408 | + * @return integer true if success |
|
409 | 409 | * */ |
410 | 410 | public static function relationUrlUsergroupExist($userGroupId, $urlId) |
411 | 411 | { |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @author Julio Montoya |
425 | 425 | * @param int user id |
426 | 426 | * @param int url id |
427 | - * @return boolean true if success |
|
427 | + * @return integer true if success |
|
428 | 428 | * */ |
429 | 429 | public static function relation_url_session_exist($session_id, $url_id) |
430 | 430 | { |
@@ -545,6 +545,8 @@ discard block |
||
545 | 545 | * @author Julio Montoya |
546 | 546 | * @param array of course ids |
547 | 547 | * @param array of url_ids |
548 | + * @param integer[] $courseCategoryList |
|
549 | + * @param integer[] $urlList |
|
548 | 550 | * @return array |
549 | 551 | **/ |
550 | 552 | public static function addCourseCategoryListToUrl($courseCategoryList, $urlList) |
@@ -575,7 +577,7 @@ discard block |
||
575 | 577 | * @author Julio Montoya |
576 | 578 | * @param int $categoryCourseId |
577 | 579 | * @param int $urlId |
578 | - * @return boolean true if success |
|
580 | + * @return integer true if success |
|
579 | 581 | * */ |
580 | 582 | public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId) |
581 | 583 | { |
@@ -592,7 +594,7 @@ discard block |
||
592 | 594 | /** |
593 | 595 | * @param int $userGroupId |
594 | 596 | * @param int $urlId |
595 | - * @return int |
|
597 | + * @return string |
|
596 | 598 | */ |
597 | 599 | public static function addUserGroupToUrl($userGroupId, $urlId) |
598 | 600 | { |
@@ -692,7 +694,7 @@ discard block |
||
692 | 694 | * @param int $courseId |
693 | 695 | * @param int $url_id |
694 | 696 | * |
695 | - * @return resource |
|
697 | + * @return boolean |
|
696 | 698 | */ |
697 | 699 | public static function add_course_to_url($courseId, $url_id = 1) |
698 | 700 | { |
@@ -763,7 +765,7 @@ discard block |
||
763 | 765 | * @param int $courseId |
764 | 766 | * @param int $urlId |
765 | 767 | * |
766 | - * @return boolean true if success |
|
768 | + * @return Doctrine\DBAL\Driver\Statement|null true if success |
|
767 | 769 | * */ |
768 | 770 | public static function delete_url_rel_course($courseId, $urlId) |
769 | 771 | { |
@@ -781,7 +783,7 @@ discard block |
||
781 | 783 | * @param int $userGroupId |
782 | 784 | * @param int $urlId |
783 | 785 | * |
784 | - * @return boolean true if success |
|
786 | + * @return Doctrine\DBAL\Driver\Statement|null true if success |
|
785 | 787 | * */ |
786 | 788 | public static function delete_url_rel_usergroup($userGroupId, $urlId) |
787 | 789 | { |
@@ -800,7 +802,7 @@ discard block |
||
800 | 802 | * @param int $userGroupId |
801 | 803 | * @param int $urlId |
802 | 804 | * |
803 | - * @return boolean true if success |
|
805 | + * @return Doctrine\DBAL\Driver\Statement|null true if success |
|
804 | 806 | * */ |
805 | 807 | public static function deleteUrlRelCourseCategory($userGroupId, $urlId) |
806 | 808 | { |
@@ -819,7 +821,7 @@ discard block |
||
819 | 821 | * @param char course code |
820 | 822 | * @param int url id |
821 | 823 | * |
822 | - * @return boolean true if success |
|
824 | + * @return Doctrine\DBAL\Driver\Statement|null true if success |
|
823 | 825 | * */ |
824 | 826 | public static function delete_url_rel_session($session_id, $url_id) |
825 | 827 | { |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | class UrlManager |
12 | 12 | { |
13 | 13 | /** |
14 | - * Creates a new url access |
|
15 | - * |
|
16 | - * @author Julio Montoya <[email protected]>, |
|
17 | - * |
|
18 | - * @param string $url The URL of the site |
|
19 | - * @param string $description The description of the site |
|
20 | - * @param int $active is active or not |
|
21 | - * @return boolean if success |
|
22 | - */ |
|
14 | + * Creates a new url access |
|
15 | + * |
|
16 | + * @author Julio Montoya <[email protected]>, |
|
17 | + * |
|
18 | + * @param string $url The URL of the site |
|
19 | + * @param string $description The description of the site |
|
20 | + * @param int $active is active or not |
|
21 | + * @return boolean if success |
|
22 | + */ |
|
23 | 23 | public static function add($url, $description, $active) |
24 | 24 | { |
25 | 25 | $tms = time(); |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | - * Updates an URL access |
|
40 | - * @author Julio Montoya <[email protected]>, |
|
41 | - * |
|
42 | - * @param int $url_id The url id |
|
43 | - * @param string $url |
|
44 | - * @param string $description The description of the site |
|
45 | - * @param int $active is active or not |
|
46 | - * @return boolean if success |
|
47 | - */ |
|
39 | + * Updates an URL access |
|
40 | + * @author Julio Montoya <[email protected]>, |
|
41 | + * |
|
42 | + * @param int $url_id The url id |
|
43 | + * @param string $url |
|
44 | + * @param string $description The description of the site |
|
45 | + * @param int $active is active or not |
|
46 | + * @return boolean if success |
|
47 | + */ |
|
48 | 48 | public static function update($url_id, $url, $description, $active) |
49 | 49 | { |
50 | 50 | $url_id = intval($url_id); |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * Deletes an url |
|
67 | - * @author Julio Montoya |
|
68 | - * @param int $id url id |
|
66 | + * Deletes an url |
|
67 | + * @author Julio Montoya |
|
68 | + * @param int $id url id |
|
69 | 69 | * |
70 | - * @return boolean true if success |
|
71 | - * */ |
|
70 | + * @return boolean true if success |
|
71 | + * */ |
|
72 | 72 | public static function delete($id) |
73 | 73 | { |
74 | 74 | $id = intval($id); |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
203 | - * Gets the inner join of access_url and the course table |
|
204 | - * |
|
205 | - * @author Julio Montoya |
|
206 | - * @param int access url id |
|
207 | - * @return array Database::store_result of the result |
|
208 | - **/ |
|
203 | + * Gets the inner join of access_url and the course table |
|
204 | + * |
|
205 | + * @author Julio Montoya |
|
206 | + * @param int access url id |
|
207 | + * @return array Database::store_result of the result |
|
208 | + **/ |
|
209 | 209 | public static function get_url_rel_course_data($access_url_id = null) |
210 | 210 | { |
211 | 211 | $where = ''; |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
365 | - * Checks the relationship between an URL and a User (return the num_rows) |
|
366 | - * @author Julio Montoya |
|
367 | - * @param int user id |
|
368 | - * @param int url id |
|
369 | - * @return boolean true if success |
|
370 | - * */ |
|
365 | + * Checks the relationship between an URL and a User (return the num_rows) |
|
366 | + * @author Julio Montoya |
|
367 | + * @param int user id |
|
368 | + * @param int url id |
|
369 | + * @return boolean true if success |
|
370 | + * */ |
|
371 | 371 | public static function relation_url_user_exist($user_id, $url_id) |
372 | 372 | { |
373 | 373 | $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | $num = Database::num_rows($result); |
378 | 378 | |
379 | 379 | return $num; |
380 | - } |
|
380 | + } |
|
381 | 381 | |
382 | 382 | /** |
383 | - * Checks the relationship between an URL and a Course (return the num_rows) |
|
384 | - * @author Julio Montoya |
|
385 | - * @param int $courseId |
|
386 | - * @param int $urlId |
|
387 | - * @return boolean true if success |
|
388 | - * */ |
|
383 | + * Checks the relationship between an URL and a Course (return the num_rows) |
|
384 | + * @author Julio Montoya |
|
385 | + * @param int $courseId |
|
386 | + * @param int $urlId |
|
387 | + * @return boolean true if success |
|
388 | + * */ |
|
389 | 389 | public static function relation_url_course_exist($courseId, $urlId) |
390 | 390 | { |
391 | 391 | $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
@@ -420,12 +420,12 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
423 | - * Checks the relationship between an URL and a Session (return the num_rows) |
|
424 | - * @author Julio Montoya |
|
425 | - * @param int user id |
|
426 | - * @param int url id |
|
427 | - * @return boolean true if success |
|
428 | - * */ |
|
423 | + * Checks the relationship between an URL and a Session (return the num_rows) |
|
424 | + * @author Julio Montoya |
|
425 | + * @param int user id |
|
426 | + * @param int url id |
|
427 | + * @return boolean true if success |
|
428 | + * */ |
|
429 | 429 | public static function relation_url_session_exist($session_id, $url_id) |
430 | 430 | { |
431 | 431 | $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
@@ -737,13 +737,13 @@ discard block |
||
737 | 737 | } |
738 | 738 | |
739 | 739 | /** |
740 | - * Deletes an url and user relationship |
|
741 | - * @author Julio Montoya |
|
742 | - * @param int user id |
|
743 | - * @param int url id |
|
740 | + * Deletes an url and user relationship |
|
741 | + * @author Julio Montoya |
|
742 | + * @param int user id |
|
743 | + * @param int url id |
|
744 | 744 | * |
745 | - * @return boolean true if success |
|
746 | - * */ |
|
745 | + * @return boolean true if success |
|
746 | + * */ |
|
747 | 747 | public static function delete_url_rel_user($user_id, $url_id) |
748 | 748 | { |
749 | 749 | $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | } |
759 | 759 | |
760 | 760 | /** |
761 | - * Deletes an url and course relationship |
|
762 | - * @author Julio Montoya |
|
763 | - * @param int $courseId |
|
764 | - * @param int $urlId |
|
761 | + * Deletes an url and course relationship |
|
762 | + * @author Julio Montoya |
|
763 | + * @param int $courseId |
|
764 | + * @param int $urlId |
|
765 | 765 | * |
766 | - * @return boolean true if success |
|
767 | - * */ |
|
766 | + * @return boolean true if success |
|
767 | + * */ |
|
768 | 768 | public static function delete_url_rel_course($courseId, $urlId) |
769 | 769 | { |
770 | 770 | $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
@@ -814,13 +814,13 @@ discard block |
||
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
817 | - * Deletes an url and session relationship |
|
818 | - * @author Julio Montoya |
|
819 | - * @param char course code |
|
820 | - * @param int url id |
|
817 | + * Deletes an url and session relationship |
|
818 | + * @author Julio Montoya |
|
819 | + * @param char course code |
|
820 | + * @param int url id |
|
821 | 821 | * |
822 | - * @return boolean true if success |
|
823 | - * */ |
|
822 | + * @return boolean true if success |
|
823 | + * */ |
|
824 | 824 | public static function delete_url_rel_session($session_id, $url_id) |
825 | 825 | { |
826 | 826 | $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
@@ -262,8 +262,9 @@ |
||
262 | 262 | $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
263 | 263 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
264 | 264 | |
265 | - if (!empty($access_url_id)) |
|
266 | - $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id); |
|
265 | + if (!empty($access_url_id)) { |
|
266 | + $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id); |
|
267 | + } |
|
267 | 268 | |
268 | 269 | $sql = "SELECT id, name, access_url_id |
269 | 270 | FROM $tbl_session u |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public static function add($url, $description, $active) |
24 | 24 | { |
25 | 25 | $tms = time(); |
26 | - $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
26 | + $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
27 | 27 | $sql = "INSERT INTO $table |
28 | 28 | SET url = '".Database::escape_string($url)."', |
29 | 29 | description = '".Database::escape_string($description)."', |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | $id = intval($id); |
75 | 75 | $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
76 | - $sql= "DELETE FROM $table WHERE id = ".$id; |
|
76 | + $sql = "DELETE FROM $table WHERE id = ".$id; |
|
77 | 77 | $result = Database::query($sql); |
78 | 78 | |
79 | 79 | return $result; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public static function url_exist($url) |
88 | 88 | { |
89 | - $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
89 | + $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
90 | 90 | $sql = "SELECT id FROM $table |
91 | 91 | WHERE url = '".Database::escape_string($url)."' "; |
92 | 92 | $res = Database::query($sql); |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | * */ |
121 | 121 | public static function url_count() |
122 | 122 | { |
123 | - $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
123 | + $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
124 | 124 | $sql = "SELECT count(id) as count_result FROM $table_access_url"; |
125 | 125 | $res = Database::query($sql); |
126 | - $url = Database::fetch_array($res,'ASSOC'); |
|
126 | + $url = Database::fetch_array($res, 'ASSOC'); |
|
127 | 127 | $result = $url['count_result']; |
128 | 128 | |
129 | 129 | return $result; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | FROM $table |
142 | 142 | ORDER BY id"; |
143 | 143 | $res = Database::query($sql); |
144 | - $urls = array (); |
|
144 | + $urls = array(); |
|
145 | 145 | while ($url = Database::fetch_array($res)) { |
146 | 146 | $urls[] = $url; |
147 | 147 | } |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | **/ |
259 | 259 | public static function get_url_rel_session_data($access_url_id = null) |
260 | 260 | { |
261 | - $where =''; |
|
261 | + $where = ''; |
|
262 | 262 | $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
263 | 263 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
264 | 264 | |
265 | 265 | if (!empty($access_url_id)) |
266 | - $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id); |
|
266 | + $where = "WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id); |
|
267 | 267 | |
268 | 268 | $sql = "SELECT id, name, access_url_id |
269 | 269 | FROM $tbl_session u |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | $table_user_group = Database::get_main_table(TABLE_USERGROUP); |
294 | 294 | |
295 | 295 | if (!empty($access_url_id)) { |
296 | - $where ="WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id); |
|
296 | + $where = "WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | $sql = "SELECT id, name, access_url_id |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | public static function relation_url_user_exist($user_id, $url_id) |
372 | 372 | { |
373 | 373 | $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
374 | - $sql= "SELECT user_id FROM $table |
|
374 | + $sql = "SELECT user_id FROM $table |
|
375 | 375 | WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." "; |
376 | 376 | $result = Database::query($sql); |
377 | 377 | $num = Database::num_rows($result); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | public static function relation_url_course_exist($courseId, $urlId) |
390 | 390 | { |
391 | 391 | $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
392 | - $sql= "SELECT c_id FROM $table_url_rel_course |
|
392 | + $sql = "SELECT c_id FROM $table_url_rel_course |
|
393 | 393 | WHERE |
394 | 394 | access_url_id = ".intval($urlId)." AND |
395 | 395 | c_id = '".intval($courseId)."'"; |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | public static function relationUrlUsergroupExist($userGroupId, $urlId) |
411 | 411 | { |
412 | 412 | $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP); |
413 | - $sql= "SELECT usergroup_id FROM $table |
|
413 | + $sql = "SELECT usergroup_id FROM $table |
|
414 | 414 | WHERE access_url_id = ".intval($urlId)." AND |
415 | 415 | usergroup_id = ".intval($userGroupId); |
416 | 416 | $result = Database::query($sql); |
@@ -428,9 +428,9 @@ discard block |
||
428 | 428 | * */ |
429 | 429 | public static function relation_url_session_exist($session_id, $url_id) |
430 | 430 | { |
431 | - $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
431 | + $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
432 | 432 | $session_id = intval($session_id); |
433 | - $url_id = intval($url_id); |
|
433 | + $url_id = intval($url_id); |
|
434 | 434 | $sql = "SELECT session_id FROM $table_url_rel_session |
435 | 435 | WHERE |
436 | 436 | access_url_id = ".intval($url_id)." AND |
@@ -453,11 +453,11 @@ discard block |
||
453 | 453 | $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
454 | 454 | $result_array = array(); |
455 | 455 | |
456 | - if (is_array($user_list) && is_array($url_list)){ |
|
456 | + if (is_array($user_list) && is_array($url_list)) { |
|
457 | 457 | foreach ($url_list as $url_id) { |
458 | 458 | foreach ($user_list as $user_id) { |
459 | - $count = UrlManager::relation_url_user_exist($user_id,$url_id); |
|
460 | - if ($count==0) { |
|
459 | + $count = UrlManager::relation_url_user_exist($user_id, $url_id); |
|
460 | + if ($count == 0) { |
|
461 | 461 | $sql = "INSERT INTO $table_url_rel_user |
462 | 462 | SET user_id = ".intval($user_id).", access_url_id = ".intval($url_id); |
463 | 463 | $result = Database::query($sql); |
@@ -482,19 +482,19 @@ discard block |
||
482 | 482 | * @param array of url_ids |
483 | 483 | * @return array |
484 | 484 | **/ |
485 | - public static function add_courses_to_urls($course_list,$url_list) |
|
485 | + public static function add_courses_to_urls($course_list, $url_list) |
|
486 | 486 | { |
487 | 487 | $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
488 | 488 | $result_array = array(); |
489 | 489 | |
490 | - if (is_array($course_list) && is_array($url_list)){ |
|
490 | + if (is_array($course_list) && is_array($url_list)) { |
|
491 | 491 | foreach ($url_list as $url_id) { |
492 | 492 | foreach ($course_list as $course_code) { |
493 | 493 | $courseInfo = api_get_course_info($course_code); |
494 | 494 | $courseId = $courseInfo['real_id']; |
495 | 495 | |
496 | 496 | $count = self::relation_url_course_exist($courseId, $url_id); |
497 | - if ($count==0) { |
|
497 | + if ($count == 0) { |
|
498 | 498 | $sql = "INSERT INTO $table_url_rel_course |
499 | 499 | SET c_id = '".$courseId."', access_url_id = ".intval($url_id); |
500 | 500 | $result = Database::query($sql); |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId) |
581 | 581 | { |
582 | 582 | $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY); |
583 | - $sql= "SELECT course_category_id FROM $table |
|
583 | + $sql = "SELECT course_category_id FROM $table |
|
584 | 584 | WHERE access_url_id = ".intval($urlId)." AND |
585 | 585 | course_category_id = ".intval($categoryCourseId); |
586 | 586 | $result = Database::query($sql); |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
750 | 750 | $result = true; |
751 | 751 | if (!empty($user_id) && !empty($url_id)) { |
752 | - $sql= "DELETE FROM $table_url_rel_user |
|
752 | + $sql = "DELETE FROM $table_url_rel_user |
|
753 | 753 | WHERE user_id = ".intval($user_id)." AND access_url_id = ".intval($url_id); |
754 | 754 | $result = Database::query($sql); |
755 | 755 | } |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
770 | 770 | $result = true; |
771 | 771 | if (!empty($userId)) { |
772 | - $sql= "DELETE FROM $table_url_rel_user |
|
772 | + $sql = "DELETE FROM $table_url_rel_user |
|
773 | 773 | WHERE user_id = ".intval($userId); |
774 | 774 | Database::query($sql); |
775 | 775 | } |
@@ -787,8 +787,8 @@ discard block |
||
787 | 787 | * */ |
788 | 788 | public static function delete_url_rel_course($courseId, $urlId) |
789 | 789 | { |
790 | - $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
791 | - $sql= "DELETE FROM $table_url_rel_course |
|
790 | + $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
791 | + $sql = "DELETE FROM $table_url_rel_course |
|
792 | 792 | WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($urlId)." "; |
793 | 793 | $result = Database::query($sql); |
794 | 794 | |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | public static function delete_url_rel_usergroup($userGroupId, $urlId) |
807 | 807 | { |
808 | 808 | $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP); |
809 | - $sql= "DELETE FROM $table |
|
809 | + $sql = "DELETE FROM $table |
|
810 | 810 | WHERE usergroup_id = '".intval($userGroupId)."' AND |
811 | 811 | access_url_id=".intval($urlId)." "; |
812 | 812 | $result = Database::query($sql); |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | public static function deleteUrlRelCourseCategory($userGroupId, $urlId) |
826 | 826 | { |
827 | 827 | $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY); |
828 | - $sql= "DELETE FROM $table |
|
828 | + $sql = "DELETE FROM $table |
|
829 | 829 | WHERE course_category_id = '".intval($userGroupId)."' AND |
830 | 830 | access_url_id=".intval($urlId)." "; |
831 | 831 | $result = Database::query($sql); |
@@ -844,9 +844,9 @@ discard block |
||
844 | 844 | public static function delete_url_rel_session($session_id, $url_id) |
845 | 845 | { |
846 | 846 | $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
847 | - $sql= "DELETE FROM $table_url_rel_session |
|
847 | + $sql = "DELETE FROM $table_url_rel_session |
|
848 | 848 | WHERE session_id = ".intval($session_id)." AND access_url_id=".intval($url_id)." "; |
849 | - $result = Database::query($sql,'ASSOC'); |
|
849 | + $result = Database::query($sql, 'ASSOC'); |
|
850 | 850 | |
851 | 851 | return $result; |
852 | 852 | } |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | * */ |
860 | 860 | public static function update_urls_rel_user($user_list, $access_url_id) |
861 | 861 | { |
862 | - $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
862 | + $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
863 | 863 | $sql = "SELECT user_id FROM $table_url_rel_user WHERE access_url_id = ".intval($access_url_id); |
864 | 864 | $result = Database::query($sql); |
865 | 865 | $existing_users = array(); |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | $result = Database::query($sql); |
914 | 914 | |
915 | 915 | $existing_courses = array(); |
916 | - while ($row = Database::fetch_array($result)){ |
|
916 | + while ($row = Database::fetch_array($result)) { |
|
917 | 917 | $existing_courses[] = $row['c_id']; |
918 | 918 | } |
919 | 919 | |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | $result = Database::query($sql); |
947 | 947 | $existingItems = array(); |
948 | 948 | |
949 | - while ($row = Database::fetch_array($result)){ |
|
949 | + while ($row = Database::fetch_array($result)) { |
|
950 | 950 | $existingItems[] = $row['usergroup_id']; |
951 | 951 | } |
952 | 952 | |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | $result = Database::query($sql); |
980 | 980 | $existingItems = array(); |
981 | 981 | |
982 | - while ($row = Database::fetch_array($result)){ |
|
982 | + while ($row = Database::fetch_array($result)) { |
|
983 | 983 | $existingItems[] = $row['course_category_id']; |
984 | 984 | } |
985 | 985 | |
@@ -1020,15 +1020,15 @@ discard block |
||
1020 | 1020 | * @param array user list |
1021 | 1021 | * @param int access_url_id |
1022 | 1022 | * */ |
1023 | - public static function update_urls_rel_session($session_list,$access_url_id) |
|
1023 | + public static function update_urls_rel_session($session_list, $access_url_id) |
|
1024 | 1024 | { |
1025 | - $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
1025 | + $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
1026 | 1026 | |
1027 | 1027 | $sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".intval($access_url_id); |
1028 | 1028 | $result = Database::query($sql); |
1029 | 1029 | $existing_sessions = array(); |
1030 | 1030 | |
1031 | - while ($row = Database::fetch_array($result)){ |
|
1031 | + while ($row = Database::fetch_array($result)) { |
|
1032 | 1032 | $existing_sessions[] = $row['session_id']; |
1033 | 1033 | } |
1034 | 1034 | |
@@ -1057,13 +1057,13 @@ discard block |
||
1057 | 1057 | */ |
1058 | 1058 | public static function get_access_url_from_user($user_id) |
1059 | 1059 | { |
1060 | - $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
1061 | - $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
1060 | + $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
1061 | + $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
1062 | 1062 | $sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u |
1063 | 1063 | ON (url_rel_user.access_url_id = u.id) |
1064 | 1064 | WHERE user_id = ".intval($user_id); |
1065 | 1065 | $result = Database::query($sql); |
1066 | - $url_list = Database::store_result($result,'ASSOC'); |
|
1066 | + $url_list = Database::store_result($result, 'ASSOC'); |
|
1067 | 1067 | return $url_list; |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1073,14 +1073,14 @@ discard block |
||
1073 | 1073 | */ |
1074 | 1074 | public static function get_access_url_from_course($courseId) |
1075 | 1075 | { |
1076 | - $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
1077 | - $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
1076 | + $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
1077 | + $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
1078 | 1078 | $sql = "SELECT url, access_url_id FROM $table c INNER JOIN $table_url u |
1079 | 1079 | ON (c.access_url_id = u.id) |
1080 | 1080 | WHERE c_id = ".intval($courseId); |
1081 | 1081 | |
1082 | 1082 | $result = Database::query($sql); |
1083 | - $url_list = Database::store_result($result,'ASSOC'); |
|
1083 | + $url_list = Database::store_result($result, 'ASSOC'); |
|
1084 | 1084 | return $url_list; |
1085 | 1085 | } |
1086 | 1086 | |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | public static function get_access_url_from_session($session_id) |
1092 | 1092 | { |
1093 | 1093 | $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
1094 | - $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
1094 | + $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
1095 | 1095 | $sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session INNER JOIN $table_url u |
1096 | 1096 | ON (url_rel_session.access_url_id = u.id) |
1097 | 1097 | WHERE session_id = ".intval($session_id); |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | */ |
1108 | 1108 | public static function get_url_id($url) |
1109 | 1109 | { |
1110 | - $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
1110 | + $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); |
|
1111 | 1111 | $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'"; |
1112 | 1112 | $result = Database::query($sql); |
1113 | 1113 | $access_url_id = Database::result($result, 0, 0); |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | * @param int $groupId |
1014 | 1014 | * @param string $picture |
1015 | 1015 | * |
1016 | - * @return bool|string |
|
1016 | + * @return false|string |
|
1017 | 1017 | */ |
1018 | 1018 | public function manageFileUpload($groupId, $picture) |
1019 | 1019 | { |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | /** |
1158 | - * @return mixed |
|
1158 | + * @return integer |
|
1159 | 1159 | */ |
1160 | 1160 | public function getGroupType() |
1161 | 1161 | { |
@@ -1359,6 +1359,8 @@ discard block |
||
1359 | 1359 | * @param string height |
1360 | 1360 | * @param string picture size it can be small_, medium_ or big_ |
1361 | 1361 | * @param string style css |
1362 | + * @param integer $height |
|
1363 | + * @param integer $size_picture |
|
1362 | 1364 | * @return array with the file and the style of an image i.e $array['file'] $array['style'] |
1363 | 1365 | */ |
1364 | 1366 | public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '') |
@@ -1420,7 +1422,7 @@ discard block |
||
1420 | 1422 | * @param string Type of path to return (can be 'none', 'system', 'rel', 'web') |
1421 | 1423 | * @param bool Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir) |
1422 | 1424 | * @param bool If we want that the function returns the /main/img/unknown.jpg image set it at true |
1423 | - * @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's |
|
1425 | + * @return integer Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's |
|
1424 | 1426 | */ |
1425 | 1427 | public function get_group_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false) |
1426 | 1428 | { |
@@ -1470,7 +1472,7 @@ discard block |
||
1470 | 1472 | } |
1471 | 1473 | |
1472 | 1474 | /** |
1473 | - * @return array |
|
1475 | + * @return string[] |
|
1474 | 1476 | */ |
1475 | 1477 | public function getAllowedPictureExtensions() |
1476 | 1478 | { |
@@ -1660,7 +1662,7 @@ discard block |
||
1660 | 1662 | * @author Julio Montoya |
1661 | 1663 | * @param int $user_id |
1662 | 1664 | * @param int $group_id |
1663 | - * @return boolean true if success |
|
1665 | + * @return Doctrine\DBAL\Driver\Statement|null true if success |
|
1664 | 1666 | * */ |
1665 | 1667 | public function delete_user_rel_group($user_id, $group_id) |
1666 | 1668 | { |
@@ -1872,6 +1874,8 @@ discard block |
||
1872 | 1874 | * @param int from value |
1873 | 1875 | * @param int limit |
1874 | 1876 | * @param array image configuration, i.e array('height'=>'20px', 'size'=> '20px') |
1877 | + * @param integer $from |
|
1878 | + * @param integer $limit |
|
1875 | 1879 | * @return array list of users in a group |
1876 | 1880 | */ |
1877 | 1881 | public function get_users_by_group( |
@@ -1970,6 +1974,8 @@ discard block |
||
1970 | 1974 | * Shows the left column of the group page |
1971 | 1975 | * @param int group id |
1972 | 1976 | * @param int user id |
1977 | + * @param integer $group_id |
|
1978 | + * @param integer $user_id |
|
1973 | 1979 | * |
1974 | 1980 | */ |
1975 | 1981 | public function show_group_column_information($group_id, $user_id, $show = '') |
@@ -2323,7 +2329,7 @@ discard block |
||
2323 | 2329 | * @param int $group_id |
2324 | 2330 | * @param int $parent_group_id if 0, we delete the parent_group association |
2325 | 2331 | * @param int $relation_type |
2326 | - * @return resource |
|
2332 | + * @return Doctrine\DBAL\Driver\Statement|null |
|
2327 | 2333 | **/ |
2328 | 2334 | public static function set_parent_group($group_id, $parent_group_id, $relation_type = 1) |
2329 | 2335 | { |
@@ -1906,8 +1906,9 @@ |
||
1906 | 1906 | $new_relation_type[] ="'$rel'"; |
1907 | 1907 | } |
1908 | 1908 | $relation_type = implode(',', $new_relation_type); |
1909 | - if (!empty($relation_type)) |
|
1910 | - $where_relation_condition = "AND gu.relation_type IN ($relation_type) "; |
|
1909 | + if (!empty($relation_type)) { |
|
1910 | + $where_relation_condition = "AND gu.relation_type IN ($relation_type) "; |
|
1911 | + } |
|
1911 | 1912 | } |
1912 | 1913 | |
1913 | 1914 | $sql = "SELECT picture_uri as image, u.id, u.firstname, u.lastname, relation_type |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | "; |
83 | 83 | $result = Database::query($sql); |
84 | 84 | if (Database::num_rows($result)) { |
85 | - $row = Database::fetch_array($result); |
|
85 | + $row = Database::fetch_array($result); |
|
86 | 86 | |
87 | 87 | return $row['count']; |
88 | 88 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | "; |
103 | 103 | $result = Database::query($sql); |
104 | 104 | if (Database::num_rows($result)) { |
105 | - $row = Database::fetch_array($result); |
|
105 | + $row = Database::fetch_array($result); |
|
106 | 106 | return $row['count']; |
107 | 107 | } |
108 | 108 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | "; |
128 | 128 | $result = Database::query($sql); |
129 | 129 | if (Database::num_rows($result)) { |
130 | - $row = Database::fetch_array($result); |
|
130 | + $row = Database::fetch_array($result); |
|
131 | 131 | return $row['count']; |
132 | 132 | } |
133 | 133 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | "; |
149 | 149 | $result = Database::query($sql); |
150 | 150 | if (Database::num_rows($result)) { |
151 | - $row = Database::fetch_array($result); |
|
151 | + $row = Database::fetch_array($result); |
|
152 | 152 | return $row['count']; |
153 | 153 | } |
154 | 154 | |
@@ -529,13 +529,13 @@ discard block |
||
529 | 529 | INNER JOIN {$this->table} g |
530 | 530 | ON (u.usergroup_id = g.id) |
531 | 531 | "; |
532 | - $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); |
|
532 | + $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); |
|
533 | 533 | } else { |
534 | 534 | $from = $this->usergroup_rel_user_table." u |
535 | 535 | INNER JOIN {$this->table} g |
536 | 536 | ON (u.usergroup_id = g.id) |
537 | 537 | "; |
538 | - $where = array('where' => array('user_id = ?' => $userId)); |
|
538 | + $where = array('where' => array('user_id = ?' => $userId)); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | if ($filterByType !== null) { |
@@ -568,10 +568,10 @@ discard block |
||
568 | 568 | $urlId = api_get_current_access_url_id(); |
569 | 569 | $from = $this->usergroup_rel_user_table." u |
570 | 570 | INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id AND u.usergroup_id)"; |
571 | - $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); |
|
571 | + $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); |
|
572 | 572 | } else { |
573 | 573 | $from = $this->usergroup_rel_user_table." u "; |
574 | - $where = array('where' => array('user_id = ?' => $userId)); |
|
574 | + $where = array('where' => array('user_id = ?' => $userId)); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | $results = Database::select( |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | } |
858 | 858 | $result = $new_result; |
859 | 859 | } |
860 | - $columns = array('name', 'users', 'courses','sessions', 'group_type'); |
|
860 | + $columns = array('name', 'users', 'courses', 'sessions', 'group_type'); |
|
861 | 861 | |
862 | 862 | if (!in_array($sidx, $columns)) { |
863 | 863 | $sidx = 'name'; |
@@ -1263,7 +1263,7 @@ discard block |
||
1263 | 1263 | } |
1264 | 1264 | } |
1265 | 1265 | } |
1266 | - $response->addAssign('ajax_list_courses','innerHTML', api_utf8_encode($return)); |
|
1266 | + $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return)); |
|
1267 | 1267 | |
1268 | 1268 | return $response; |
1269 | 1269 | } |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | * @param string style css |
1373 | 1373 | * @return array with the file and the style of an image i.e $array['file'] $array['style'] |
1374 | 1374 | */ |
1375 | - public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '') |
|
1375 | + public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '') |
|
1376 | 1376 | { |
1377 | 1377 | $picture = array(); |
1378 | 1378 | $picture['style'] = $style; |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | if (file_exists($file) && !is_dir($file)) { |
1416 | 1416 | $picture['file'] = $image_array['dir'].$picture_file; |
1417 | 1417 | } else { |
1418 | - $picture['file'] = Display::returnIconPath('group_na.png',64); |
|
1418 | + $picture['file'] = Display::returnIconPath('group_na.png', 64); |
|
1419 | 1419 | } |
1420 | 1420 | } |
1421 | 1421 | return $picture; |
@@ -1485,7 +1485,7 @@ discard block |
||
1485 | 1485 | */ |
1486 | 1486 | public function getAllowedPictureExtensions() |
1487 | 1487 | { |
1488 | - return $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); |
|
1488 | + return $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); |
|
1489 | 1489 | } |
1490 | 1490 | |
1491 | 1491 | /** |
@@ -1519,7 +1519,7 @@ discard block |
||
1519 | 1519 | if (empty($user_id)) { |
1520 | 1520 | $user_id = api_get_user_id(); |
1521 | 1521 | } |
1522 | - $user_role = $this->get_user_group_role($user_id, $group_id); |
|
1522 | + $user_role = $this->get_user_group_role($user_id, $group_id); |
|
1523 | 1523 | if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN))) { |
1524 | 1524 | return true; |
1525 | 1525 | } else { |
@@ -1537,7 +1537,7 @@ discard block |
||
1537 | 1537 | if (empty($user_id)) { |
1538 | 1538 | $user_id = api_get_user_id(); |
1539 | 1539 | } |
1540 | - $user_role = $this->get_user_group_role($user_id, $group_id); |
|
1540 | + $user_role = $this->get_user_group_role($user_id, $group_id); |
|
1541 | 1541 | if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) { |
1542 | 1542 | return true; |
1543 | 1543 | } else { |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | GROUP_USER_PERMISSION_READER, |
1565 | 1565 | GROUP_USER_PERMISSION_HRM, |
1566 | 1566 | ); |
1567 | - $user_role = self::get_user_group_role($user_id, $group_id); |
|
1567 | + $user_role = self::get_user_group_role($user_id, $group_id); |
|
1568 | 1568 | if (in_array($user_role, $roles)) { |
1569 | 1569 | return true; |
1570 | 1570 | } else { |
@@ -1581,7 +1581,7 @@ discard block |
||
1581 | 1581 | * */ |
1582 | 1582 | public function get_user_group_role($user_id, $group_id) |
1583 | 1583 | { |
1584 | - $table_group_rel_user= $this->usergroup_rel_user_table; |
|
1584 | + $table_group_rel_user = $this->usergroup_rel_user_table; |
|
1585 | 1585 | $return_value = 0; |
1586 | 1586 | if (!empty($user_id) && !empty($group_id)) { |
1587 | 1587 | $sql = "SELECT relation_type FROM $table_group_rel_user |
@@ -1589,8 +1589,8 @@ discard block |
||
1589 | 1589 | usergroup_id = ".intval($group_id)." AND |
1590 | 1590 | user_id = ".intval($user_id)." "; |
1591 | 1591 | $result = Database::query($sql); |
1592 | - if (Database::num_rows($result)>0) { |
|
1593 | - $row = Database::fetch_array($result,'ASSOC'); |
|
1592 | + if (Database::num_rows($result) > 0) { |
|
1593 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
1594 | 1594 | $return_value = $row['relation_type']; |
1595 | 1595 | } |
1596 | 1596 | } |
@@ -1645,7 +1645,7 @@ discard block |
||
1645 | 1645 | if (is_array($user_list) && is_array($group_list)) { |
1646 | 1646 | foreach ($group_list as $group_id) { |
1647 | 1647 | foreach ($user_list as $user_id) { |
1648 | - $role = self::get_user_group_role($user_id,$group_id); |
|
1648 | + $role = self::get_user_group_role($user_id, $group_id); |
|
1649 | 1649 | if ($role == 0) { |
1650 | 1650 | $sql = "INSERT INTO $table_url_rel_group |
1651 | 1651 | SET |
@@ -1676,7 +1676,7 @@ discard block |
||
1676 | 1676 | public function delete_user_rel_group($user_id, $group_id) |
1677 | 1677 | { |
1678 | 1678 | $table = $this->usergroup_rel_user_table; |
1679 | - $sql= "DELETE FROM $table |
|
1679 | + $sql = "DELETE FROM $table |
|
1680 | 1680 | WHERE |
1681 | 1681 | user_id = ".intval($user_id)." AND |
1682 | 1682 | usergroup_id = ".intval($group_id)." "; |
@@ -1732,7 +1732,7 @@ discard block |
||
1732 | 1732 | |
1733 | 1733 | $sql = "UPDATE $table_group_rel_user |
1734 | 1734 | SET relation_type = ".intval($relation_type)." |
1735 | - WHERE user_id = $user_id AND usergroup_id = $group_id" ; |
|
1735 | + WHERE user_id = $user_id AND usergroup_id = $group_id"; |
|
1736 | 1736 | Database::query($sql); |
1737 | 1737 | } |
1738 | 1738 | |
@@ -1774,7 +1774,7 @@ discard block |
||
1774 | 1774 | if (Database::num_rows($result) > 0) { |
1775 | 1775 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
1776 | 1776 | if ($with_image) { |
1777 | - $picture = self::get_picture_group($row['id'], $row['picture'],80); |
|
1777 | + $picture = self::get_picture_group($row['id'], $row['picture'], 80); |
|
1778 | 1778 | $img = '<img src="'.$picture['file'].'" />'; |
1779 | 1779 | $row['picture'] = $img; |
1780 | 1780 | } |
@@ -1810,11 +1810,11 @@ discard block |
||
1810 | 1810 | ORDER BY count DESC |
1811 | 1811 | LIMIT $num"; |
1812 | 1812 | |
1813 | - $result=Database::query($sql); |
|
1813 | + $result = Database::query($sql); |
|
1814 | 1814 | $array = array(); |
1815 | 1815 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
1816 | 1816 | if ($with_image) { |
1817 | - $picture = self::get_picture_group($row['id'], $row['picture'],80); |
|
1817 | + $picture = self::get_picture_group($row['id'], $row['picture'], 80); |
|
1818 | 1818 | $img = '<img src="'.$picture['file'].'" />'; |
1819 | 1819 | $row['picture'] = $img; |
1820 | 1820 | } |
@@ -1859,11 +1859,11 @@ discard block |
||
1859 | 1859 | ORDER BY created_at DESC |
1860 | 1860 | LIMIT $num "; |
1861 | 1861 | |
1862 | - $result=Database::query($sql); |
|
1862 | + $result = Database::query($sql); |
|
1863 | 1863 | $array = array(); |
1864 | 1864 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
1865 | 1865 | if ($with_image) { |
1866 | - $picture = self::get_picture_group($row['id'], $row['picture'],80); |
|
1866 | + $picture = self::get_picture_group($row['id'], $row['picture'], 80); |
|
1867 | 1867 | $img = '<img src="'.$picture['file'].'" />'; |
1868 | 1868 | $row['picture'] = $img; |
1869 | 1869 | } |
@@ -1897,7 +1897,7 @@ discard block |
||
1897 | 1897 | $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
1898 | 1898 | $group_id = intval($group_id); |
1899 | 1899 | |
1900 | - if (empty($group_id)){ |
|
1900 | + if (empty($group_id)) { |
|
1901 | 1901 | return array(); |
1902 | 1902 | } |
1903 | 1903 | |
@@ -1912,9 +1912,9 @@ discard block |
||
1912 | 1912 | $where_relation_condition = ''; |
1913 | 1913 | } else { |
1914 | 1914 | $new_relation_type = array(); |
1915 | - foreach($relation_type as $rel) { |
|
1915 | + foreach ($relation_type as $rel) { |
|
1916 | 1916 | $rel = intval($rel); |
1917 | - $new_relation_type[] ="'$rel'"; |
|
1917 | + $new_relation_type[] = "'$rel'"; |
|
1918 | 1918 | } |
1919 | 1919 | $relation_type = implode(',', $new_relation_type); |
1920 | 1920 | if (!empty($relation_type)) |
@@ -1958,7 +1958,7 @@ discard block |
||
1958 | 1958 | $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
1959 | 1959 | $group_id = intval($group_id); |
1960 | 1960 | |
1961 | - if (empty($group_id)){ |
|
1961 | + if (empty($group_id)) { |
|
1962 | 1962 | return array(); |
1963 | 1963 | } |
1964 | 1964 | |
@@ -1969,7 +1969,7 @@ discard block |
||
1969 | 1969 | WHERE gu.usergroup_id= $group_id |
1970 | 1970 | ORDER BY relation_type, firstname"; |
1971 | 1971 | |
1972 | - $result=Database::query($sql); |
|
1972 | + $result = Database::query($sql); |
|
1973 | 1973 | $array = array(); |
1974 | 1974 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
1975 | 1975 | $array[$row['id']] = $row; |
@@ -1998,33 +1998,33 @@ discard block |
||
1998 | 1998 | case GROUP_USER_PERMISSION_READER: |
1999 | 1999 | // I'm just a reader |
2000 | 2000 | $relation_group_title = get_lang('IAmAReader'); |
2001 | - $links .= '<li class="'. ($show == 'invite_friends' ? 'active' : '') .'"><a href="group_invitation.php?id='.$group_id.'">'. |
|
2002 | - Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>'; |
|
2003 | - $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2004 | - Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>'; |
|
2001 | + $links .= '<li class="'.($show == 'invite_friends' ? 'active' : '').'"><a href="group_invitation.php?id='.$group_id.'">'. |
|
2002 | + Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>'; |
|
2003 | + $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2004 | + Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>'; |
|
2005 | 2005 | if (UserGroup::canLeave($group_info)) { |
2006 | - $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2007 | - Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>'; |
|
2006 | + $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2007 | + Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>'; |
|
2008 | 2008 | } |
2009 | 2009 | break; |
2010 | 2010 | case GROUP_USER_PERMISSION_ADMIN: |
2011 | 2011 | $relation_group_title = get_lang('IAmAnAdmin'); |
2012 | - $links .= '<li class="'. ($show == 'group_edit' ? 'active' : '') .'"><a href="group_edit.php?id='.$group_id.'">'. |
|
2013 | - Display::return_icon('group_edit.png', get_lang('EditGroup')) . get_lang('EditGroup') . '</a></li>'; |
|
2014 | - $links .= '<li class="'. ($show == 'member_list' ? 'active' : '') .'"><a href="group_waiting_list.php?id='.$group_id.'">'. |
|
2015 | - Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '</a></li>'; |
|
2016 | - $links .= '<li class="'. ($show == 'invite_friends' ? 'active' : '') .'"><a href="group_invitation.php?id='.$group_id.'">'. |
|
2017 | - Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>'; |
|
2012 | + $links .= '<li class="'.($show == 'group_edit' ? 'active' : '').'"><a href="group_edit.php?id='.$group_id.'">'. |
|
2013 | + Display::return_icon('group_edit.png', get_lang('EditGroup')).get_lang('EditGroup').'</a></li>'; |
|
2014 | + $links .= '<li class="'.($show == 'member_list' ? 'active' : '').'"><a href="group_waiting_list.php?id='.$group_id.'">'. |
|
2015 | + Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'</a></li>'; |
|
2016 | + $links .= '<li class="'.($show == 'invite_friends' ? 'active' : '').'"><a href="group_invitation.php?id='.$group_id.'">'. |
|
2017 | + Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>'; |
|
2018 | 2018 | if (UserGroup::canLeave($group_info)) { |
2019 | 2019 | $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
2020 | - Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>'; |
|
2020 | + Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>'; |
|
2021 | 2021 | } |
2022 | 2022 | break; |
2023 | 2023 | case GROUP_USER_PERMISSION_PENDING_INVITATION: |
2024 | 2024 | // $links .= '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('YouHaveBeenInvitedJoinNow'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouHaveBeenInvitedJoinNow').'</span></a></li>'; |
2025 | 2025 | break; |
2026 | 2026 | case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER: |
2027 | - $relation_group_title = get_lang('WaitingForAdminResponse'); |
|
2027 | + $relation_group_title = get_lang('WaitingForAdminResponse'); |
|
2028 | 2028 | break; |
2029 | 2029 | case GROUP_USER_PERMISSION_MODERATOR: |
2030 | 2030 | $relation_group_title = get_lang('IAmAModerator'); |
@@ -2032,28 +2032,28 @@ discard block |
||
2032 | 2032 | //$links .= '<li><a href="groups.php?id='.$group_id.'">'. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>'; |
2033 | 2033 | //$links .= '<li><a href="group_members.php?id='.$group_id.'">'. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>'; |
2034 | 2034 | if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) { |
2035 | - $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'. |
|
2036 | - Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '</a></li>'; |
|
2035 | + $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'. |
|
2036 | + Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'</a></li>'; |
|
2037 | 2037 | } |
2038 | - $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
2039 | - Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>'; |
|
2038 | + $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
2039 | + Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>'; |
|
2040 | 2040 | if (UserGroup::canLeave($group_info)) { |
2041 | - $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2042 | - Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>'; |
|
2041 | + $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2042 | + Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>'; |
|
2043 | 2043 | } |
2044 | 2044 | break; |
2045 | 2045 | case GROUP_USER_PERMISSION_HRM: |
2046 | 2046 | $relation_group_title = get_lang('IAmAHRM'); |
2047 | 2047 | $links .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="ajax" title="'.get_lang('ComposeMessage').'" data-size="lg" data-title="'.get_lang('ComposeMessage').'">'. |
2048 | - Display::return_icon('new-message.png', get_lang('NewTopic')) . get_lang('NewTopic') . '</a></li>'; |
|
2049 | - $links .= '<li><a href="group_view.php?id='.$group_id.'">'. |
|
2050 | - Display::return_icon('message_list.png', get_lang('MessageList')) . get_lang('MessageList') . '</a></li>'; |
|
2051 | - $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
2052 | - Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>'; |
|
2053 | - $links .= '<li><a href="group_members.php?id='.$group_id.'">'. |
|
2054 | - Display::return_icon('member_list.png', get_lang('MemberList')) . get_lang('MemberList') . '</a></li>'; |
|
2055 | - $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2056 | - Display::return_icon('delete_data.gif', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>'; |
|
2048 | + Display::return_icon('new-message.png', get_lang('NewTopic')).get_lang('NewTopic').'</a></li>'; |
|
2049 | + $links .= '<li><a href="group_view.php?id='.$group_id.'">'. |
|
2050 | + Display::return_icon('message_list.png', get_lang('MessageList')).get_lang('MessageList').'</a></li>'; |
|
2051 | + $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
2052 | + Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>'; |
|
2053 | + $links .= '<li><a href="group_members.php?id='.$group_id.'">'. |
|
2054 | + Display::return_icon('member_list.png', get_lang('MemberList')).get_lang('MemberList').'</a></li>'; |
|
2055 | + $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2056 | + Display::return_icon('delete_data.gif', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>'; |
|
2057 | 2057 | break; |
2058 | 2058 | default: |
2059 | 2059 | //$links .= '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('JoinGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('JoinGroup').'</a></span></li>'; |
@@ -2090,14 +2090,14 @@ discard block |
||
2090 | 2090 | */ |
2091 | 2091 | public function get_groups_by_user_count($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) |
2092 | 2092 | { |
2093 | - $table_group_rel_user = $this->usergroup_rel_user_table; |
|
2094 | - $tbl_group = $this->table; |
|
2095 | - $user_id = intval($user_id); |
|
2093 | + $table_group_rel_user = $this->usergroup_rel_user_table; |
|
2094 | + $tbl_group = $this->table; |
|
2095 | + $user_id = intval($user_id); |
|
2096 | 2096 | |
2097 | 2097 | if ($relation_type == 0) { |
2098 | 2098 | $where_relation_condition = ''; |
2099 | 2099 | } else { |
2100 | - $relation_type = intval($relation_type); |
|
2100 | + $relation_type = intval($relation_type); |
|
2101 | 2101 | $where_relation_condition = "AND gu.relation_type = $relation_type "; |
2102 | 2102 | } |
2103 | 2103 | |
@@ -2170,7 +2170,7 @@ discard block |
||
2170 | 2170 | } |
2171 | 2171 | |
2172 | 2172 | $direction = 'ASC'; |
2173 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
2173 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
2174 | 2174 | $direction = 'ASC'; |
2175 | 2175 | } |
2176 | 2176 | |
@@ -2181,8 +2181,8 @@ discard block |
||
2181 | 2181 | $sql .= " LIMIT $from,$number_of_items"; |
2182 | 2182 | |
2183 | 2183 | $res = Database::query($sql); |
2184 | - if (Database::num_rows($res)> 0) { |
|
2185 | - while ($row = Database::fetch_array($res,'ASSOC')) { |
|
2184 | + if (Database::num_rows($res) > 0) { |
|
2185 | + while ($row = Database::fetch_array($res, 'ASSOC')) { |
|
2186 | 2186 | if (!in_array($row['id'], $return)) { |
2187 | 2187 | $return[$row['id']] = $row; |
2188 | 2188 | } |
@@ -2207,7 +2207,7 @@ discard block |
||
2207 | 2207 | if ($i == $max_level) { |
2208 | 2208 | $select_part .= "rg$rg_number.group_id as id_$rg_number "; |
2209 | 2209 | } else { |
2210 | - $select_part .="rg$rg_number.group_id as id_$rg_number, "; |
|
2210 | + $select_part .= "rg$rg_number.group_id as id_$rg_number, "; |
|
2211 | 2211 | } |
2212 | 2212 | if ($i == 1) { |
2213 | 2213 | $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id "; |
@@ -2395,7 +2395,7 @@ discard block |
||
2395 | 2395 | $nameList = '<ul class="list-unstyled">'; |
2396 | 2396 | |
2397 | 2397 | foreach ($groupsNameListParsed as $name) { |
2398 | - $nameList .= '<li>' . Display::span($name, ['class' => 'label label-info']) . '</li>'; |
|
2398 | + $nameList .= '<li>'.Display::span($name, ['class' => 'label label-info']).'</li>'; |
|
2399 | 2399 | } |
2400 | 2400 | |
2401 | 2401 | $nameList .= '</ul>'; |
@@ -43,7 +43,7 @@ |
||
43 | 43 | * Create a video chat |
44 | 44 | * @param int $fromUser The sender user |
45 | 45 | * @param int $toUser The receiver user |
46 | - * @return int The created video chat id. Otherwise return false |
|
46 | + * @return false|string The created video chat id. Otherwise return false |
|
47 | 47 | */ |
48 | 48 | public static function createRoom($fromUser, $toUser) |
49 | 49 | { |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | * Returns the current request mode (XAJAX_GET or XAJAX_POST), or -1 if |
501 | 501 | * there is none. |
502 | 502 | * |
503 | - * @return mixed |
|
503 | + * @return integer |
|
504 | 504 | */ |
505 | 505 | function getRequestMode() |
506 | 506 | { |
@@ -1018,6 +1018,7 @@ discard block |
||
1018 | 1018 | * |
1019 | 1019 | * @param string the root tag of the XML |
1020 | 1020 | * @param string XML to convert |
1021 | + * @param string $rootTag |
|
1021 | 1022 | * @access private |
1022 | 1023 | * @return array |
1023 | 1024 | */ |
@@ -173,8 +173,9 @@ discard block |
||
173 | 173 | $this->aObjects = array(); |
174 | 174 | $this->aFunctionIncludeFiles = array(); |
175 | 175 | $this->sRequestURI = $sRequestURI; |
176 | - if ($this->sRequestURI == "") |
|
177 | - $this->sRequestURI = $this->_detectURI(); |
|
176 | + if ($this->sRequestURI == "") { |
|
177 | + $this->sRequestURI = $this->_detectURI(); |
|
178 | + } |
|
178 | 179 | $this->sWrapperPrefix = $sWrapperPrefix; |
179 | 180 | $this->bDebug = $bDebug; |
180 | 181 | $this->bStatusMessages = false; |
@@ -399,8 +400,7 @@ discard block |
||
399 | 400 | $this->aFunctions[$mFunction[0]] = 1; |
400 | 401 | $this->aFunctionRequestTypes[$mFunction[0]] = $sRequestType; |
401 | 402 | $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1); |
402 | - } |
|
403 | - else { |
|
403 | + } else { |
|
404 | 404 | $this->aFunctions[$mFunction] = 1; |
405 | 405 | $this->aFunctionRequestTypes[$mFunction] = $sRequestType; |
406 | 406 | } |
@@ -426,8 +426,7 @@ discard block |
||
426 | 426 | |
427 | 427 | if (is_array($mFunction)) { |
428 | 428 | $this->aFunctionIncludeFiles[$mFunction[0]] = $sIncludeFile; |
429 | - } |
|
430 | - else { |
|
429 | + } else { |
|
431 | 430 | $this->aFunctionIncludeFiles[$mFunction] = $sIncludeFile; |
432 | 431 | } |
433 | 432 | } |
@@ -451,8 +450,7 @@ discard block |
||
451 | 450 | if (is_array($mFunction)) { |
452 | 451 | $this->sCatchAllFunction = $mFunction[0]; |
453 | 452 | $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1); |
454 | - } |
|
455 | - else { |
|
453 | + } else { |
|
456 | 454 | $this->sCatchAllFunction = $mFunction; |
457 | 455 | } |
458 | 456 | } |
@@ -477,8 +475,7 @@ discard block |
||
477 | 475 | if (is_array($mFunction)) { |
478 | 476 | $this->sPreFunction = $mFunction[0]; |
479 | 477 | $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1); |
480 | - } |
|
481 | - else { |
|
478 | + } else { |
|
482 | 479 | $this->sPreFunction = $mFunction; |
483 | 480 | } |
484 | 481 | } |
@@ -492,7 +489,9 @@ discard block |
||
492 | 489 | */ |
493 | 490 | function canProcessRequests() |
494 | 491 | { |
495 | - if ($this->getRequestMode() != -1) return true; |
|
492 | + if ($this->getRequestMode() != -1) { |
|
493 | + return true; |
|
494 | + } |
|
496 | 495 | return false; |
497 | 496 | } |
498 | 497 | |
@@ -504,11 +503,13 @@ discard block |
||
504 | 503 | */ |
505 | 504 | function getRequestMode() |
506 | 505 | { |
507 | - if (!empty($_GET["xajax"])) |
|
508 | - return XAJAX_GET; |
|
506 | + if (!empty($_GET["xajax"])) { |
|
507 | + return XAJAX_GET; |
|
508 | + } |
|
509 | 509 | |
510 | - if (!empty($_POST["xajax"])) |
|
511 | - return XAJAX_POST; |
|
510 | + if (!empty($_POST["xajax"])) { |
|
511 | + return XAJAX_POST; |
|
512 | + } |
|
512 | 513 | |
513 | 514 | return -1; |
514 | 515 | } |
@@ -535,16 +536,18 @@ discard block |
||
535 | 536 | $sResponse = ""; |
536 | 537 | |
537 | 538 | $requestMode = $this->getRequestMode(); |
538 | - if ($requestMode == -1) return; |
|
539 | + if ($requestMode == -1) { |
|
540 | + return; |
|
541 | + } |
|
539 | 542 | |
540 | 543 | if ($requestMode == XAJAX_POST) |
541 | 544 | { |
542 | 545 | $sFunctionName = $_POST["xajax"]; |
543 | 546 | |
544 | - if (!empty($_POST["xajaxargs"])) |
|
545 | - $aArgs = $_POST["xajaxargs"]; |
|
546 | - } |
|
547 | - else |
|
547 | + if (!empty($_POST["xajaxargs"])) { |
|
548 | + $aArgs = $_POST["xajaxargs"]; |
|
549 | + } |
|
550 | + } else |
|
548 | 551 | { |
549 | 552 | header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
550 | 553 | header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
@@ -553,8 +556,9 @@ discard block |
||
553 | 556 | |
554 | 557 | $sFunctionName = $_GET["xajax"]; |
555 | 558 | |
556 | - if (!empty($_GET["xajaxargs"])) |
|
557 | - $aArgs = $_GET["xajaxargs"]; |
|
559 | + if (!empty($_GET["xajaxargs"])) { |
|
560 | + $aArgs = $_GET["xajaxargs"]; |
|
561 | + } |
|
558 | 562 | } |
559 | 563 | |
560 | 564 | // Use xajax error handler if necessary |
@@ -586,15 +590,13 @@ discard block |
||
586 | 590 | if ($this->sCatchAllFunction) { |
587 | 591 | $sFunctionName = $this->sCatchAllFunction; |
588 | 592 | $bFunctionIsCatchAll = true; |
589 | - } |
|
590 | - else { |
|
593 | + } else { |
|
591 | 594 | $bFoundFunction = false; |
592 | 595 | $objResponse = new xajaxResponse(); |
593 | 596 | $objResponse->addAlert("Unknown Function $sFunctionName."); |
594 | 597 | $sResponse = $objResponse->getXML(); |
595 | 598 | } |
596 | - } |
|
597 | - else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode) |
|
599 | + } else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode) |
|
598 | 600 | { |
599 | 601 | $bFoundFunction = false; |
600 | 602 | $objResponse = new xajaxResponse(); |
@@ -615,12 +617,10 @@ discard block |
||
615 | 617 | if (stristr($aArgs[$i],"<xjxobj>") != false) |
616 | 618 | { |
617 | 619 | $aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]); |
618 | - } |
|
619 | - else if (stristr($aArgs[$i],"<xjxquery>") != false) |
|
620 | + } else if (stristr($aArgs[$i],"<xjxquery>") != false) |
|
620 | 621 | { |
621 | 622 | $aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]); |
622 | - } |
|
623 | - else if ($this->bDecodeUTF8Input) |
|
623 | + } else if ($this->bDecodeUTF8Input) |
|
624 | 624 | { |
625 | 625 | $aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]); |
626 | 626 | } |
@@ -631,14 +631,15 @@ discard block |
||
631 | 631 | if (is_array($mPreResponse) && $mPreResponse[0] === false) { |
632 | 632 | $bEndRequest = true; |
633 | 633 | $sPreResponse = $mPreResponse[1]; |
634 | - } |
|
635 | - else { |
|
634 | + } else { |
|
636 | 635 | $sPreResponse = $mPreResponse; |
637 | 636 | } |
638 | 637 | if (is_a($sPreResponse, "xajaxResponse")) { |
639 | 638 | $sPreResponse = $sPreResponse->getXML(); |
640 | 639 | } |
641 | - if ($bEndRequest) $sResponse = $sPreResponse; |
|
640 | + if ($bEndRequest) { |
|
641 | + $sResponse = $sPreResponse; |
|
642 | + } |
|
642 | 643 | } |
643 | 644 | |
644 | 645 | if (!$bEndRequest) { |
@@ -646,8 +647,7 @@ discard block |
||
646 | 647 | $objResponse = new xajaxResponse(); |
647 | 648 | $objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found."); |
648 | 649 | $sResponse = $objResponse->getXML(); |
649 | - } |
|
650 | - else { |
|
650 | + } else { |
|
651 | 651 | if ($bFunctionIsCatchAll) { |
652 | 652 | $aArgs = array($sFunctionNameForSpecial, $aArgs); |
653 | 653 | } |
@@ -660,8 +660,7 @@ discard block |
||
660 | 660 | $objResponse = new xajaxResponse(); |
661 | 661 | $objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName."); |
662 | 662 | $sResponse = $objResponse->getXML(); |
663 | - } |
|
664 | - else if ($sPreResponse != "") { |
|
663 | + } else if ($sPreResponse != "") { |
|
665 | 664 | $sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities); |
666 | 665 | $sNewResponse->loadXML($sPreResponse); |
667 | 666 | $sNewResponse->loadXML($sResponse); |
@@ -671,8 +670,9 @@ discard block |
||
671 | 670 | } |
672 | 671 | |
673 | 672 | $sContentHeader = "Content-type: text/xml;"; |
674 | - if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
|
675 | - $sContentHeader .= " charset=".$this->sEncoding; |
|
673 | + if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) { |
|
674 | + $sContentHeader .= " charset=".$this->sEncoding; |
|
675 | + } |
|
676 | 676 | header($sContentHeader); |
677 | 677 | if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) { |
678 | 678 | $sErrorResponse = new xajaxResponse(); |
@@ -681,8 +681,7 @@ discard block |
||
681 | 681 | $fH = @fopen($this->sLogFile, "a"); |
682 | 682 | if (!$fH) { |
683 | 683 | $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile); |
684 | - } |
|
685 | - else { |
|
684 | + } else { |
|
686 | 685 | fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n"); |
687 | 686 | fclose($fH); |
688 | 687 | } |
@@ -692,12 +691,17 @@ discard block |
||
692 | 691 | $sResponse = $sErrorResponse->getXML(); |
693 | 692 | |
694 | 693 | } |
695 | - if ($this->bCleanBuffer) while (@ob_end_clean()); |
|
694 | + if ($this->bCleanBuffer) { |
|
695 | + while (@ob_end_clean()); |
|
696 | + } |
|
696 | 697 | print $sResponse; |
697 | - if ($this->bErrorHandler) restore_error_handler(); |
|
698 | + if ($this->bErrorHandler) { |
|
699 | + restore_error_handler(); |
|
700 | + } |
|
698 | 701 | |
699 | - if ($this->bExitAllowed) |
|
700 | - exit(); |
|
702 | + if ($this->bExitAllowed) { |
|
703 | + exit(); |
|
704 | + } |
|
701 | 705 | } |
702 | 706 | |
703 | 707 | /** |
@@ -806,9 +810,13 @@ discard block |
||
806 | 810 | */ |
807 | 811 | function getJavascriptInclude($sJsURI="", $sJsFile=NULL) |
808 | 812 | { |
809 | - if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js"; |
|
813 | + if ($sJsFile == NULL) { |
|
814 | + $sJsFile = "xajax_js/xajax.js"; |
|
815 | + } |
|
810 | 816 | |
811 | - if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/"; |
|
817 | + if ($sJsURI != "" && substr($sJsURI, -1) != "/") { |
|
818 | + $sJsURI .= "/"; |
|
819 | + } |
|
812 | 820 | |
813 | 821 | $html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n"; |
814 | 822 | $html .= "\t<script type=\"text/javascript\">\n"; |
@@ -831,8 +839,7 @@ discard block |
||
831 | 839 | |
832 | 840 | if ($sJsFullFilename) { |
833 | 841 | $realJsFile = $sJsFullFilename; |
834 | - } |
|
835 | - else { |
|
842 | + } else { |
|
836 | 843 | $realPath = realpath(dirname(__FILE__)); |
837 | 844 | $realJsFile = $realPath . "/". $sJsFile; |
838 | 845 | } |
@@ -849,8 +856,7 @@ discard block |
||
849 | 856 | $fH = @fopen($realJsFile, "w"); |
850 | 857 | if (!$fH) { |
851 | 858 | trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR); |
852 | - } |
|
853 | - else { |
|
859 | + } else { |
|
854 | 860 | fwrite($fH, $compressedScript); |
855 | 861 | fclose($fH); |
856 | 862 | } |
@@ -950,7 +956,9 @@ discard block |
||
950 | 956 | */ |
951 | 957 | function _isObjectCallback($sFunction) |
952 | 958 | { |
953 | - if (array_key_exists($sFunction, $this->aObjects)) return true; |
|
959 | + if (array_key_exists($sFunction, $this->aObjects)) { |
|
960 | + return true; |
|
961 | + } |
|
954 | 962 | return false; |
955 | 963 | } |
956 | 964 | |
@@ -967,12 +975,10 @@ discard block |
||
967 | 975 | if ($this->_isObjectCallback($sFunction)) { |
968 | 976 | if (is_object($this->aObjects[$sFunction][0])) { |
969 | 977 | return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]); |
970 | - } |
|
971 | - else { |
|
978 | + } else { |
|
972 | 979 | return is_callable($this->aObjects[$sFunction]); |
973 | 980 | } |
974 | - } |
|
975 | - else { |
|
981 | + } else { |
|
976 | 982 | return function_exists($sFunction); |
977 | 983 | } |
978 | 984 | } |
@@ -990,8 +996,7 @@ discard block |
||
990 | 996 | { |
991 | 997 | if ($this->_isObjectCallback($sFunction)) { |
992 | 998 | $mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs); |
993 | - } |
|
994 | - else { |
|
999 | + } else { |
|
995 | 1000 | $mReturn = call_user_func_array($sFunction, $aArgs); |
996 | 1001 | } |
997 | 1002 | return $mReturn; |
@@ -1086,8 +1091,7 @@ discard block |
||
1086 | 1091 | { |
1087 | 1092 | $value = $this->_parseObjXml("xjxobj"); |
1088 | 1093 | $this->iPos++; |
1089 | - } |
|
1090 | - else |
|
1094 | + } else |
|
1091 | 1095 | { |
1092 | 1096 | $value .= $this->aObjArray[$this->iPos]; |
1093 | 1097 | if ($this->bDecodeUTF8Input) |
@@ -1134,10 +1138,11 @@ discard block |
||
1134 | 1138 | if (get_magic_quotes_gpc() == 1) { |
1135 | 1139 | $newArray = array(); |
1136 | 1140 | foreach ($aArray as $sKey => $sValue) { |
1137 | - if (is_string($sValue)) |
|
1138 | - $newArray[$sKey] = stripslashes($sValue); |
|
1139 | - else |
|
1140 | - $newArray[$sKey] = $sValue; |
|
1141 | + if (is_string($sValue)) { |
|
1142 | + $newArray[$sKey] = stripslashes($sValue); |
|
1143 | + } else { |
|
1144 | + $newArray[$sKey] = $sValue; |
|
1145 | + } |
|
1141 | 1146 | } |
1142 | 1147 | $aArray = $newArray; |
1143 | 1148 | } |
@@ -1166,20 +1171,18 @@ discard block |
||
1166 | 1171 | $sFuncToUse = "api_convert_encoding"; |
1167 | 1172 | } |
1168 | 1173 | //if (function_exists('iconv')) |
1169 | - elseif (function_exists('iconv')) |
|
1170 | - // |
|
1174 | + elseif (function_exists('iconv')) { |
|
1175 | + // |
|
1171 | 1176 | { |
1172 | 1177 | $sFuncToUse = "iconv"; |
1173 | 1178 | } |
1174 | - else if (function_exists('mb_convert_encoding')) |
|
1179 | + } else if (function_exists('mb_convert_encoding')) |
|
1175 | 1180 | { |
1176 | 1181 | $sFuncToUse = "mb_convert_encoding"; |
1177 | - } |
|
1178 | - else if ($this->sEncoding == "ISO-8859-1") |
|
1182 | + } else if ($this->sEncoding == "ISO-8859-1") |
|
1179 | 1183 | { |
1180 | 1184 | $sFuncToUse = "utf8_decode"; |
1181 | - } |
|
1182 | - else |
|
1185 | + } else |
|
1183 | 1186 | { |
1184 | 1187 | trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE); |
1185 | 1188 | } |
@@ -1191,8 +1194,7 @@ discard block |
||
1191 | 1194 | if ($sFuncToUse == "iconv") |
1192 | 1195 | { |
1193 | 1196 | $sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue); |
1194 | - } |
|
1195 | - else if ($sFuncToUse == "mb_convert_encoding") |
|
1197 | + } else if ($sFuncToUse == "mb_convert_encoding") |
|
1196 | 1198 | { |
1197 | 1199 | $sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8"); |
1198 | 1200 | } |
@@ -1221,27 +1223,23 @@ discard block |
||
1221 | 1223 | function xajaxErrorHandler($errno, $errstr, $errfile, $errline) |
1222 | 1224 | { |
1223 | 1225 | $errorReporting = error_reporting(); |
1224 | - if (($errno & $errorReporting) == 0) return; |
|
1226 | + if (($errno & $errorReporting) == 0) { |
|
1227 | + return; |
|
1228 | + } |
|
1225 | 1229 | |
1226 | 1230 | if ($errno == E_NOTICE) { |
1227 | 1231 | $errTypeStr = "NOTICE"; |
1228 | - } |
|
1229 | - else if ($errno == E_WARNING) { |
|
1232 | + } else if ($errno == E_WARNING) { |
|
1230 | 1233 | $errTypeStr = "WARNING"; |
1231 | - } |
|
1232 | - else if ($errno == E_USER_NOTICE) { |
|
1234 | + } else if ($errno == E_USER_NOTICE) { |
|
1233 | 1235 | $errTypeStr = "USER NOTICE"; |
1234 | - } |
|
1235 | - else if ($errno == E_USER_WARNING) { |
|
1236 | + } else if ($errno == E_USER_WARNING) { |
|
1236 | 1237 | $errTypeStr = "USER WARNING"; |
1237 | - } |
|
1238 | - else if ($errno == E_USER_ERROR) { |
|
1238 | + } else if ($errno == E_USER_ERROR) { |
|
1239 | 1239 | $errTypeStr = "USER FATAL ERROR"; |
1240 | - } |
|
1241 | - else if ($errno == E_STRICT) { |
|
1240 | + } else if ($errno == E_STRICT) { |
|
1242 | 1241 | return; |
1243 | - } |
|
1244 | - else { |
|
1242 | + } else { |
|
1245 | 1243 | $errTypeStr = "UNKNOWN: $errno"; |
1246 | 1244 | } |
1247 | 1245 | $GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile"; |
@@ -45,21 +45,21 @@ discard block |
||
45 | 45 | * Define XAJAX_DEFAULT_CHAR_ENCODING that is used by both |
46 | 46 | * the xajax and xajaxResponse classes |
47 | 47 | */ |
48 | -if (!defined ('XAJAX_DEFAULT_CHAR_ENCODING')) |
|
48 | +if (!defined('XAJAX_DEFAULT_CHAR_ENCODING')) |
|
49 | 49 | { |
50 | - define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8' ); |
|
50 | + define('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Communication Method Defines |
55 | 55 | */ |
56 | -if (!defined ('XAJAX_GET')) |
|
56 | +if (!defined('XAJAX_GET')) |
|
57 | 57 | { |
58 | - define ('XAJAX_GET', 0); |
|
58 | + define('XAJAX_GET', 0); |
|
59 | 59 | } |
60 | -if (!defined ('XAJAX_POST')) |
|
60 | +if (!defined('XAJAX_POST')) |
|
61 | 61 | { |
62 | - define ('XAJAX_POST', 1); |
|
62 | + define('XAJAX_POST', 1); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param string defaults to XAJAX_DEFAULT_CHAR_ENCODING defined above |
168 | 168 | * @param boolean defaults to false |
169 | 169 | */ |
170 | - public function __construct($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false) |
|
170 | + public function __construct($sRequestURI = "", $sWrapperPrefix = "xajax_", $sEncoding = XAJAX_DEFAULT_CHAR_ENCODING, $bDebug = false) |
|
171 | 171 | { |
172 | 172 | $this->aFunctions = array(); |
173 | 173 | $this->aObjects = array(); |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param mixed request type (XAJAX_GET/XAJAX_POST) that should be used |
394 | 394 | * for this function. Defaults to XAJAX_POST. |
395 | 395 | */ |
396 | - function registerFunction($mFunction,$sRequestType=XAJAX_POST) |
|
396 | + function registerFunction($mFunction, $sRequestType = XAJAX_POST) |
|
397 | 397 | { |
398 | 398 | if (is_array($mFunction)) { |
399 | 399 | $this->aFunctions[$mFunction[0]] = 1; |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | * @param mixed the RequestType (XAJAX_GET/XAJAX_POST) that should be used |
421 | 421 | * for this function. Defaults to XAJAX_POST. |
422 | 422 | */ |
423 | - function registerExternalFunction($mFunction,$sIncludeFile,$sRequestType=XAJAX_POST) |
|
423 | + function registerExternalFunction($mFunction, $sIncludeFile, $sRequestType = XAJAX_POST) |
|
424 | 424 | { |
425 | 425 | $this->registerFunction($mFunction, $sRequestType); |
426 | 426 | |
@@ -545,10 +545,10 @@ discard block |
||
545 | 545 | } |
546 | 546 | else |
547 | 547 | { |
548 | - header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
549 | - header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
550 | - header ("Cache-Control: no-cache, must-revalidate"); |
|
551 | - header ("Pragma: no-cache"); |
|
548 | + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
549 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
550 | + header("Cache-Control: no-cache, must-revalidate"); |
|
551 | + header("Pragma: no-cache"); |
|
552 | 552 | |
553 | 553 | $sFunctionName = $_GET["xajax"]; |
554 | 554 | |
@@ -566,12 +566,12 @@ discard block |
||
566 | 566 | if (!$this->_isFunctionCallable($this->sPreFunction)) { |
567 | 567 | $bFoundFunction = false; |
568 | 568 | $objResponse = new xajaxResponse(); |
569 | - $objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction); |
|
569 | + $objResponse->addAlert("Unknown Pre-Function ".$this->sPreFunction); |
|
570 | 570 | $sResponse = $objResponse->getXML(); |
571 | 571 | } |
572 | 572 | } |
573 | 573 | //include any external dependencies associated with this function name |
574 | - if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles)) |
|
574 | + if (array_key_exists($sFunctionName, $this->aFunctionIncludeFiles)) |
|
575 | 575 | { |
576 | 576 | ob_start(); |
577 | 577 | include_once($this->aFunctionIncludeFiles[$sFunctionName]); |
@@ -611,13 +611,13 @@ discard block |
||
611 | 611 | |
612 | 612 | $aArgs[$i] = stripslashes($aArgs[$i]); |
613 | 613 | } |
614 | - if (stristr($aArgs[$i],"<xjxobj>") != false) |
|
614 | + if (stristr($aArgs[$i], "<xjxobj>") != false) |
|
615 | 615 | { |
616 | - $aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]); |
|
616 | + $aArgs[$i] = $this->_xmlToArray("xjxobj", $aArgs[$i]); |
|
617 | 617 | } |
618 | - else if (stristr($aArgs[$i],"<xjxquery>") != false) |
|
618 | + else if (stristr($aArgs[$i], "<xjxquery>") != false) |
|
619 | 619 | { |
620 | - $aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]); |
|
620 | + $aArgs[$i] = $this->_xmlToArray("xjxquery", $aArgs[$i]); |
|
621 | 621 | } |
622 | 622 | else if ($this->bDecodeUTF8Input) |
623 | 623 | { |
@@ -673,16 +673,16 @@ discard block |
||
673 | 673 | if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
674 | 674 | $sContentHeader .= " charset=".$this->sEncoding; |
675 | 675 | header($sContentHeader); |
676 | - if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) { |
|
676 | + if ($this->bErrorHandler && !empty($GLOBALS['xajaxErrorHandlerText'])) { |
|
677 | 677 | $sErrorResponse = new xajaxResponse(); |
678 | - $sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']); |
|
678 | + $sErrorResponse->addAlert("** PHP Error Messages: **".$GLOBALS['xajaxErrorHandlerText']); |
|
679 | 679 | if ($this->sLogFile) { |
680 | 680 | $fH = @fopen($this->sLogFile, "a"); |
681 | 681 | if (!$fH) { |
682 | - $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile); |
|
682 | + $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n".$this->sLogFile); |
|
683 | 683 | } |
684 | 684 | else { |
685 | - fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n"); |
|
685 | + fwrite($fH, "** xajax Error Log - ".strftime("%b %e %Y %I:%M:%S %p")." **".$GLOBALS['xajaxErrorHandlerText']."\n\n\n"); |
|
686 | 686 | fclose($fH); |
687 | 687 | } |
688 | 688 | } |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | * engine located within the xajax installation folder. |
725 | 725 | * Defaults to xajax_js/xajax.js. |
726 | 726 | */ |
727 | - function printJavascript($sJsURI="", $sJsFile=NULL) |
|
727 | + function printJavascript($sJsURI = "", $sJsFile = NULL) |
|
728 | 728 | { |
729 | 729 | print $this->getJavascript($sJsURI, $sJsFile); |
730 | 730 | } |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | * Defaults to xajax_js/xajax.js. |
754 | 754 | * @return string |
755 | 755 | */ |
756 | - function getJavascript($sJsURI="", $sJsFile=NULL) |
|
756 | + function getJavascript($sJsURI = "", $sJsFile = NULL) |
|
757 | 757 | { |
758 | 758 | $html = $this->getJavascriptConfig(); |
759 | 759 | $html .= $this->getJavascriptInclude($sJsURI, $sJsFile); |
@@ -771,15 +771,15 @@ discard block |
||
771 | 771 | { |
772 | 772 | $html = "\t<script type=\"text/javascript\">\n"; |
773 | 773 | $html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n"; |
774 | - $html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n"; |
|
775 | - $html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n"; |
|
776 | - $html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n"; |
|
774 | + $html .= "var xajaxDebug=".($this->bDebug ? "true" : "false").";\n"; |
|
775 | + $html .= "var xajaxStatusMessages=".($this->bStatusMessages ? "true" : "false").";\n"; |
|
776 | + $html .= "var xajaxWaitCursor=".($this->bWaitCursor ? "true" : "false").";\n"; |
|
777 | 777 | $html .= "var xajaxDefinedGet=".XAJAX_GET.";\n"; |
778 | 778 | $html .= "var xajaxDefinedPost=".XAJAX_POST.";\n"; |
779 | 779 | $html .= "var xajaxLoaded=false;\n"; |
780 | 780 | |
781 | - foreach($this->aFunctions as $sFunction => $bExists) { |
|
782 | - $html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]); |
|
781 | + foreach ($this->aFunctions as $sFunction => $bExists) { |
|
782 | + $html .= $this->_wrap($sFunction, $this->aFunctionRequestTypes[$sFunction]); |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | $html .= "\t</script>\n"; |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | * Defaults to xajax_js/xajax.js. |
804 | 804 | * @return string |
805 | 805 | */ |
806 | - function getJavascriptInclude($sJsURI="", $sJsFile=NULL) |
|
806 | + function getJavascriptInclude($sJsURI = "", $sJsFile = NULL) |
|
807 | 807 | { |
808 | 808 | //if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js"; |
809 | 809 | $sJsFile = "xajax_js/xajax.js"; |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | //if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/"; |
812 | 812 | $sJsURI = api_get_path(WEB_LIBRARY_JS_PATH); |
813 | 813 | |
814 | - $html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n"; |
|
814 | + $html = "\t<script type=\"text/javascript\" src=\"".$sJsURI.$sJsFile."\"></script>\n"; |
|
815 | 815 | $html .= "\t<script type=\"text/javascript\">\n"; |
816 | 816 | $html .= "window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\\nURL: {$sJsURI}{$sJsFile}'); } }, 6000);\n"; |
817 | 817 | $html .= "\t</script>\n"; |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | * @param string an optional argument containing the full server file path |
827 | 827 | * of xajax.js. |
828 | 828 | */ |
829 | - function autoCompressJavascript($sJsFullFilename=NULL) |
|
829 | + function autoCompressJavascript($sJsFullFilename = NULL) |
|
830 | 830 | { |
831 | 831 | $sJsFile = "xajax_js/xajax.js"; |
832 | 832 | |
@@ -835,21 +835,21 @@ discard block |
||
835 | 835 | } |
836 | 836 | else { |
837 | 837 | $realPath = realpath(dirname(__FILE__)); |
838 | - $realJsFile = $realPath . "/". $sJsFile; |
|
838 | + $realJsFile = $realPath."/".$sJsFile; |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | // Create a compressed file if necessary |
842 | 842 | if (!file_exists($realJsFile)) { |
843 | 843 | $srcFile = str_replace(".js", "_uncompressed.js", $realJsFile); |
844 | 844 | if (!file_exists($srcFile)) { |
845 | - trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR); |
|
845 | + trigger_error("The xajax uncompressed Javascript file could not be found in the <b>".dirname($realJsFile)."</b> folder. Error ", E_USER_ERROR); |
|
846 | 846 | } |
847 | 847 | require(dirname(__FILE__)."/xajaxCompress.php"); |
848 | 848 | $javaScript = implode('', file($srcFile)); |
849 | 849 | $compressedScript = xajaxCompressJavascript($javaScript); |
850 | 850 | $fH = @fopen($realJsFile, "w"); |
851 | 851 | if (!$fH) { |
852 | - trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR); |
|
852 | + trigger_error("The xajax compressed javascript file could not be written in the <b>".dirname($realJsFile)."</b> folder. Error ", E_USER_ERROR); |
|
853 | 853 | } |
854 | 854 | else { |
855 | 855 | fwrite($fH, $compressedScript); |
@@ -918,23 +918,23 @@ discard block |
||
918 | 918 | // Build the URL: Start with scheme, user and pass |
919 | 919 | $sURL = $aURL['scheme'].'://'; |
920 | 920 | if (!empty($aURL['user'])) { |
921 | - $sURL.= $aURL['user']; |
|
921 | + $sURL .= $aURL['user']; |
|
922 | 922 | if (!empty($aURL['pass'])) { |
923 | - $sURL.= ':'.$aURL['pass']; |
|
923 | + $sURL .= ':'.$aURL['pass']; |
|
924 | 924 | } |
925 | - $sURL.= '@'; |
|
925 | + $sURL .= '@'; |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | // Add the host |
929 | - $sURL.= $aURL['host']; |
|
929 | + $sURL .= $aURL['host']; |
|
930 | 930 | |
931 | 931 | // Add the port if needed |
932 | 932 | if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) { |
933 | - $sURL.= ':'.$aURL['port']; |
|
933 | + $sURL .= ':'.$aURL['port']; |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | // Add the path and the query string |
937 | - $sURL.= $aURL['path'].@$aURL['query']; |
|
937 | + $sURL .= $aURL['path'].@$aURL['query']; |
|
938 | 938 | |
939 | 939 | // Clean up |
940 | 940 | unset($aURL); |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | * @access private |
1007 | 1007 | * @return string |
1008 | 1008 | */ |
1009 | - function _wrap($sFunction,$sRequestType=XAJAX_POST) |
|
1009 | + function _wrap($sFunction, $sRequestType = XAJAX_POST) |
|
1010 | 1010 | { |
1011 | 1011 | $js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n"; |
1012 | 1012 | return $js; |
@@ -1025,18 +1025,18 @@ discard block |
||
1025 | 1025 | function _xmlToArray($rootTag, $sXml) |
1026 | 1026 | { |
1027 | 1027 | $aArray = array(); |
1028 | - $sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml); |
|
1029 | - $sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml); |
|
1030 | - $sXml = str_replace("<e>","<e>|~|",$sXml); |
|
1031 | - $sXml = str_replace("</e>","</e>|~|",$sXml); |
|
1032 | - $sXml = str_replace("<k>","<k>|~|",$sXml); |
|
1033 | - $sXml = str_replace("</k>","|~|</k>|~|",$sXml); |
|
1034 | - $sXml = str_replace("<v>","<v>|~|",$sXml); |
|
1035 | - $sXml = str_replace("</v>","|~|</v>|~|",$sXml); |
|
1036 | - $sXml = str_replace("<q>","<q>|~|",$sXml); |
|
1037 | - $sXml = str_replace("</q>","|~|</q>|~|",$sXml); |
|
1038 | - |
|
1039 | - $this->aObjArray = explode("|~|",$sXml); |
|
1028 | + $sXml = str_replace("<$rootTag>", "<$rootTag>|~|", $sXml); |
|
1029 | + $sXml = str_replace("</$rootTag>", "</$rootTag>|~|", $sXml); |
|
1030 | + $sXml = str_replace("<e>", "<e>|~|", $sXml); |
|
1031 | + $sXml = str_replace("</e>", "</e>|~|", $sXml); |
|
1032 | + $sXml = str_replace("<k>", "<k>|~|", $sXml); |
|
1033 | + $sXml = str_replace("</k>", "|~|</k>|~|", $sXml); |
|
1034 | + $sXml = str_replace("<v>", "<v>|~|", $sXml); |
|
1035 | + $sXml = str_replace("</v>", "|~|</v>|~|", $sXml); |
|
1036 | + $sXml = str_replace("<q>", "<q>|~|", $sXml); |
|
1037 | + $sXml = str_replace("</q>", "|~|</q>|~|", $sXml); |
|
1038 | + |
|
1039 | + $this->aObjArray = explode("|~|", $sXml); |
|
1040 | 1040 | |
1041 | 1041 | $this->iPos = 0; |
1042 | 1042 | $aArray = $this->_parseObjXml($rootTag); |
@@ -1058,32 +1058,32 @@ discard block |
||
1058 | 1058 | |
1059 | 1059 | if ($rootTag == "xjxobj") |
1060 | 1060 | { |
1061 | - while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>")) |
|
1061 | + while (!stristr($this->aObjArray[$this->iPos], "</xjxobj>")) |
|
1062 | 1062 | { |
1063 | 1063 | $this->iPos++; |
1064 | - if(stristr($this->aObjArray[$this->iPos],"<e>")) |
|
1064 | + if (stristr($this->aObjArray[$this->iPos], "<e>")) |
|
1065 | 1065 | { |
1066 | 1066 | $key = ""; |
1067 | 1067 | $value = null; |
1068 | 1068 | |
1069 | 1069 | $this->iPos++; |
1070 | - while(!stristr($this->aObjArray[$this->iPos],"</e>")) |
|
1070 | + while (!stristr($this->aObjArray[$this->iPos], "</e>")) |
|
1071 | 1071 | { |
1072 | - if(stristr($this->aObjArray[$this->iPos],"<k>")) |
|
1072 | + if (stristr($this->aObjArray[$this->iPos], "<k>")) |
|
1073 | 1073 | { |
1074 | 1074 | $this->iPos++; |
1075 | - while(!stristr($this->aObjArray[$this->iPos],"</k>")) |
|
1075 | + while (!stristr($this->aObjArray[$this->iPos], "</k>")) |
|
1076 | 1076 | { |
1077 | 1077 | $key .= $this->aObjArray[$this->iPos]; |
1078 | 1078 | $this->iPos++; |
1079 | 1079 | } |
1080 | 1080 | } |
1081 | - if(stristr($this->aObjArray[$this->iPos],"<v>")) |
|
1081 | + if (stristr($this->aObjArray[$this->iPos], "<v>")) |
|
1082 | 1082 | { |
1083 | 1083 | $this->iPos++; |
1084 | - while(!stristr($this->aObjArray[$this->iPos],"</v>")) |
|
1084 | + while (!stristr($this->aObjArray[$this->iPos], "</v>")) |
|
1085 | 1085 | { |
1086 | - if(stristr($this->aObjArray[$this->iPos],"<xjxobj>")) |
|
1086 | + if (stristr($this->aObjArray[$this->iPos], "<xjxobj>")) |
|
1087 | 1087 | { |
1088 | 1088 | $value = $this->_parseObjXml("xjxobj"); |
1089 | 1089 | $this->iPos++; |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | $this->iPos++; |
1103 | 1103 | } |
1104 | 1104 | |
1105 | - $aArray[$key]=$value; |
|
1105 | + $aArray[$key] = $value; |
|
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | } |
@@ -1111,21 +1111,21 @@ discard block |
||
1111 | 1111 | { |
1112 | 1112 | $sQuery = ""; |
1113 | 1113 | $this->iPos++; |
1114 | - while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>")) |
|
1114 | + while (!stristr($this->aObjArray[$this->iPos], "</xjxquery>")) |
|
1115 | 1115 | { |
1116 | - if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>")) |
|
1116 | + if (stristr($this->aObjArray[$this->iPos], "<q>") || stristr($this->aObjArray[$this->iPos], "</q>")) |
|
1117 | 1117 | { |
1118 | 1118 | $this->iPos++; |
1119 | 1119 | continue; |
1120 | 1120 | } |
1121 | - $sQuery .= $this->aObjArray[$this->iPos]; |
|
1121 | + $sQuery .= $this->aObjArray[$this->iPos]; |
|
1122 | 1122 | $this->iPos++; |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | parse_str($sQuery, $aArray); |
1126 | 1126 | if ($this->bDecodeUTF8Input) |
1127 | 1127 | { |
1128 | - foreach($aArray as $key => $value) |
|
1128 | + foreach ($aArray as $key => $value) |
|
1129 | 1129 | { |
1130 | 1130 | $aArray[$key] = $this->_decodeUTF8Data($value); |
1131 | 1131 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | if (!defined ('XAJAX_DEFAULT_CHAR_ENCODING')) |
49 | 49 | { |
50 | - define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8' ); |
|
50 | + define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8' ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | if (!defined ('XAJAX_GET')) |
57 | 57 | { |
58 | - define ('XAJAX_GET', 0); |
|
58 | + define ('XAJAX_GET', 0); |
|
59 | 59 | } |
60 | 60 | if (!defined ('XAJAX_POST')) |
61 | 61 | { |
62 | - define ('XAJAX_POST', 1); |
|
62 | + define ('XAJAX_POST', 1); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -72,1144 +72,1144 @@ discard block |
||
72 | 72 | */ |
73 | 73 | class xajax |
74 | 74 | { |
75 | - /**#@+ |
|
75 | + /**#@+ |
|
76 | 76 | * @access protected |
77 | 77 | */ |
78 | - /** |
|
79 | - * @var array Array of PHP functions that will be callable through javascript wrappers |
|
80 | - */ |
|
81 | - var $aFunctions; |
|
82 | - /** |
|
83 | - * @var array Array of object callbacks that will allow Javascript to call PHP methods (key=function name) |
|
84 | - */ |
|
85 | - var $aObjects; |
|
86 | - /** |
|
87 | - * @var array Array of RequestTypes to be used with each function (key=function name) |
|
88 | - */ |
|
89 | - var $aFunctionRequestTypes; |
|
90 | - /** |
|
91 | - * @var array Array of Include Files for any external functions (key=function name) |
|
92 | - */ |
|
93 | - var $aFunctionIncludeFiles; |
|
94 | - /** |
|
95 | - * @var string Name of the PHP function to call if no callable function was found |
|
96 | - */ |
|
97 | - var $sCatchAllFunction; |
|
98 | - /** |
|
99 | - * @var string Name of the PHP function to call before any other function |
|
100 | - */ |
|
101 | - var $sPreFunction; |
|
102 | - /** |
|
103 | - * @var string The URI for making requests to the xajax object |
|
104 | - */ |
|
105 | - var $sRequestURI; |
|
106 | - /** |
|
107 | - * @var string The prefix to prepend to the javascript wraper function name |
|
108 | - */ |
|
109 | - var $sWrapperPrefix; |
|
110 | - /** |
|
111 | - * @var boolean Show debug messages (default false) |
|
112 | - */ |
|
113 | - var $bDebug; |
|
114 | - /** |
|
115 | - * @var boolean Show messages in the client browser's status bar (default false) |
|
116 | - */ |
|
117 | - var $bStatusMessages; |
|
118 | - /** |
|
119 | - * @var boolean Allow xajax to exit after processing a request (default true) |
|
120 | - */ |
|
121 | - var $bExitAllowed; |
|
122 | - /** |
|
123 | - * @var boolean Use wait cursor in browser (default true) |
|
124 | - */ |
|
125 | - var $bWaitCursor; |
|
126 | - /** |
|
127 | - * @var boolean Use an special xajax error handler so the errors are sent to the browser properly (default false) |
|
128 | - */ |
|
129 | - var $bErrorHandler; |
|
130 | - /** |
|
131 | - * @var string Specify what, if any, file xajax should log errors to (and more information in a future release) |
|
132 | - */ |
|
133 | - var $sLogFile; |
|
134 | - /** |
|
135 | - * @var boolean Clean all output buffers before outputting response (default false) |
|
136 | - */ |
|
137 | - var $bCleanBuffer; |
|
138 | - /** |
|
139 | - * @var string String containing the character encoding used |
|
140 | - */ |
|
141 | - var $sEncoding; |
|
142 | - /** |
|
143 | - * @var boolean Decode input request args from UTF-8 (default false) |
|
144 | - */ |
|
145 | - var $bDecodeUTF8Input; |
|
146 | - /** |
|
147 | - * @var boolean Convert special characters to HTML entities (default false) |
|
148 | - */ |
|
149 | - var $bOutputEntities; |
|
150 | - /** |
|
151 | - * @var array Array for parsing complex objects |
|
152 | - */ |
|
153 | - var $aObjArray; |
|
154 | - /** |
|
155 | - * @var integer Position in $aObjArray |
|
156 | - */ |
|
157 | - var $iPos; |
|
158 | - |
|
159 | - /**#@-*/ |
|
160 | - |
|
161 | - /** |
|
162 | - * Constructor. You can set some extra xajax options right away or use |
|
163 | - * individual methods later to set options. |
|
164 | - * |
|
165 | - * @param string defaults to the current browser URI |
|
166 | - * @param string defaults to "xajax_"; |
|
167 | - * @param string defaults to XAJAX_DEFAULT_CHAR_ENCODING defined above |
|
168 | - * @param boolean defaults to false |
|
169 | - */ |
|
170 | - public function __construct($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false) |
|
171 | - { |
|
172 | - $this->aFunctions = array(); |
|
173 | - $this->aObjects = array(); |
|
174 | - $this->aFunctionIncludeFiles = array(); |
|
175 | - $this->sRequestURI = $sRequestURI; |
|
176 | - if ($this->sRequestURI == "") |
|
177 | - $this->sRequestURI = $this->_detectURI(); |
|
178 | - $this->sWrapperPrefix = $sWrapperPrefix; |
|
179 | - $this->bDebug = $bDebug; |
|
180 | - $this->bStatusMessages = false; |
|
181 | - $this->bWaitCursor = true; |
|
182 | - $this->bExitAllowed = true; |
|
183 | - $this->bErrorHandler = false; |
|
184 | - $this->sLogFile = ""; |
|
185 | - $this->bCleanBuffer = false; |
|
186 | - $this->setCharEncoding($sEncoding); |
|
187 | - $this->bDecodeUTF8Input = false; |
|
188 | - $this->bOutputEntities = false; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Sets the URI to which requests will be made. |
|
193 | - * <i>Usage:</i> <kbd>$xajax->setRequestURI("http://www.xajaxproject.org");</kbd> |
|
194 | - * |
|
195 | - * @param string the URI (can be absolute or relative) of the PHP script |
|
196 | - * that will be accessed when an xajax request occurs |
|
197 | - */ |
|
198 | - function setRequestURI($sRequestURI) |
|
199 | - { |
|
200 | - $this->sRequestURI = $sRequestURI; |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Sets the prefix that will be appended to the Javascript wrapper |
|
205 | - * functions (default is "xajax_"). |
|
206 | - * |
|
207 | - * @param string |
|
208 | - */ |
|
209 | - // |
|
210 | - function setWrapperPrefix($sPrefix) |
|
211 | - { |
|
212 | - $this->sWrapperPrefix = $sPrefix; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Enables debug messages for xajax. |
|
217 | - * */ |
|
218 | - function debugOn() |
|
219 | - { |
|
220 | - $this->bDebug = true; |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * Disables debug messages for xajax (default behavior). |
|
225 | - */ |
|
226 | - function debugOff() |
|
227 | - { |
|
228 | - $this->bDebug = false; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Enables messages in the browser's status bar for xajax. |
|
233 | - */ |
|
234 | - function statusMessagesOn() |
|
235 | - { |
|
236 | - $this->bStatusMessages = true; |
|
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * Disables messages in the browser's status bar for xajax (default behavior). |
|
241 | - */ |
|
242 | - function statusMessagesOff() |
|
243 | - { |
|
244 | - $this->bStatusMessages = false; |
|
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * Enables the wait cursor to be displayed in the browser (default behavior). |
|
249 | - */ |
|
250 | - function waitCursorOn() |
|
251 | - { |
|
252 | - $this->bWaitCursor = true; |
|
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * Disables the wait cursor to be displayed in the browser. |
|
257 | - */ |
|
258 | - function waitCursorOff() |
|
259 | - { |
|
260 | - $this->bWaitCursor = false; |
|
261 | - } |
|
262 | - |
|
263 | - /** |
|
264 | - * Enables xajax to exit immediately after processing a request and |
|
265 | - * sending the response back to the browser (default behavior). |
|
266 | - */ |
|
267 | - function exitAllowedOn() |
|
268 | - { |
|
269 | - $this->bExitAllowed = true; |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * Disables xajax's default behavior of exiting immediately after |
|
274 | - * processing a request and sending the response back to the browser. |
|
275 | - */ |
|
276 | - function exitAllowedOff() |
|
277 | - { |
|
278 | - $this->bExitAllowed = false; |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * Turns on xajax's error handling system so that PHP errors that occur |
|
283 | - * during a request are trapped and pushed to the browser in the form of |
|
284 | - * a Javascript alert. |
|
285 | - */ |
|
286 | - function errorHandlerOn() |
|
287 | - { |
|
288 | - $this->bErrorHandler = true; |
|
289 | - } |
|
290 | - |
|
291 | - /** |
|
292 | - * Turns off xajax's error handling system (default behavior). |
|
293 | - */ |
|
294 | - function errorHandlerOff() |
|
295 | - { |
|
296 | - $this->bErrorHandler = false; |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * Specifies a log file that will be written to by xajax during a request |
|
301 | - * (used only by the error handling system at present). If you don't invoke |
|
302 | - * this method, or you pass in "", then no log file will be written to. |
|
303 | - * <i>Usage:</i> <kbd>$xajax->setLogFile("/xajax_logs/errors.log");</kbd> |
|
304 | - */ |
|
305 | - function setLogFile($sFilename) |
|
306 | - { |
|
307 | - $this->sLogFile = $sFilename; |
|
308 | - } |
|
309 | - |
|
310 | - /** |
|
311 | - * Causes xajax to clean out all output buffers before outputting a |
|
312 | - * response (default behavior). |
|
313 | - */ |
|
314 | - function cleanBufferOn() |
|
315 | - { |
|
316 | - $this->bCleanBuffer = true; |
|
317 | - } |
|
318 | - /** |
|
319 | - * Turns off xajax's output buffer cleaning. |
|
320 | - */ |
|
321 | - function cleanBufferOff() |
|
322 | - { |
|
323 | - $this->bCleanBuffer = false; |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Sets the character encoding for the HTTP output based on |
|
328 | - * <kbd>$sEncoding</kbd>, which is a string containing the character |
|
329 | - * encoding to use. You don't need to use this method normally, since the |
|
330 | - * character encoding for the response gets set automatically based on the |
|
331 | - * <kbd>XAJAX_DEFAULT_CHAR_ENCODING</kbd> constant. |
|
332 | - * <i>Usage:</i> <kbd>$xajax->setCharEncoding("utf-8");</kbd> |
|
333 | - * |
|
334 | - * @param string the encoding type to use (utf-8, iso-8859-1, etc.) |
|
335 | - */ |
|
336 | - function setCharEncoding($sEncoding) |
|
337 | - { |
|
338 | - $this->sEncoding = $sEncoding; |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Causes xajax to decode the input request args from UTF-8 to the current |
|
343 | - * encoding if possible. Either the iconv or mb_string extension must be |
|
344 | - * present for optimal functionality. |
|
345 | - */ |
|
346 | - function decodeUTF8InputOn() |
|
347 | - { |
|
348 | - $this->bDecodeUTF8Input = true; |
|
349 | - } |
|
350 | - |
|
351 | - /** |
|
352 | - * Turns off decoding the input request args from UTF-8 (default behavior). |
|
353 | - */ |
|
354 | - function decodeUTF8InputOff() |
|
355 | - { |
|
356 | - $this->bDecodeUTF8Input = false; |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Tells the response object to convert special characters to HTML entities |
|
361 | - * automatically (only works if the mb_string extension is available). |
|
362 | - */ |
|
363 | - function outputEntitiesOn() |
|
364 | - { |
|
365 | - $this->bOutputEntities = true; |
|
366 | - } |
|
367 | - |
|
368 | - /** |
|
369 | - * Tells the response object to output special characters intact. (default |
|
370 | - * behavior). |
|
371 | - */ |
|
372 | - function outputEntitiesOff() |
|
373 | - { |
|
374 | - $this->bOutputEntities = false; |
|
375 | - } |
|
376 | - |
|
377 | - /** |
|
378 | - * Registers a PHP function or method to be callable through xajax in your |
|
379 | - * Javascript. If you want to register a function, pass in the name of that |
|
380 | - * function. If you want to register a static class method, pass in an |
|
381 | - * array like so: |
|
382 | - * <kbd>array("myFunctionName", "myClass", "myMethod")</kbd> |
|
383 | - * For an object instance method, use an object variable for the second |
|
384 | - * array element (and in PHP 4 make sure you put an & before the variable |
|
385 | - * to pass the object by reference). Note: the function name is what you |
|
386 | - * call via Javascript, so it can be anything as long as it doesn't |
|
387 | - * conflict with any other registered function name. |
|
388 | - * |
|
389 | - * <i>Usage:</i> <kbd>$xajax->registerFunction("myFunction");</kbd> |
|
390 | - * or: <kbd>$xajax->registerFunction(array("myFunctionName", &$myObject, "myMethod"));</kbd> |
|
391 | - * |
|
392 | - * @param mixed contains the function name or an object callback array |
|
393 | - * @param mixed request type (XAJAX_GET/XAJAX_POST) that should be used |
|
394 | - * for this function. Defaults to XAJAX_POST. |
|
395 | - */ |
|
396 | - function registerFunction($mFunction,$sRequestType=XAJAX_POST) |
|
397 | - { |
|
398 | - if (is_array($mFunction)) { |
|
399 | - $this->aFunctions[$mFunction[0]] = 1; |
|
400 | - $this->aFunctionRequestTypes[$mFunction[0]] = $sRequestType; |
|
401 | - $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1); |
|
402 | - } |
|
403 | - else { |
|
404 | - $this->aFunctions[$mFunction] = 1; |
|
405 | - $this->aFunctionRequestTypes[$mFunction] = $sRequestType; |
|
406 | - } |
|
407 | - } |
|
408 | - |
|
409 | - /** |
|
410 | - * Registers a PHP function to be callable through xajax which is located |
|
411 | - * in some other file. If the function is requested the external file will |
|
412 | - * be included to define the function before the function is called. |
|
413 | - * |
|
414 | - * <i>Usage:</i> <kbd>$xajax->registerExternalFunction("myFunction","myFunction.inc.php",XAJAX_POST);</kbd> |
|
415 | - * |
|
416 | - * @param string contains the function name or an object callback array |
|
417 | - * ({@link xajax::registerFunction() see registerFunction} for |
|
418 | - * more info on object callback arrays) |
|
419 | - * @param string contains the path and filename of the include file |
|
420 | - * @param mixed the RequestType (XAJAX_GET/XAJAX_POST) that should be used |
|
421 | - * for this function. Defaults to XAJAX_POST. |
|
422 | - */ |
|
423 | - function registerExternalFunction($mFunction,$sIncludeFile,$sRequestType=XAJAX_POST) |
|
424 | - { |
|
425 | - $this->registerFunction($mFunction, $sRequestType); |
|
426 | - |
|
427 | - if (is_array($mFunction)) { |
|
428 | - $this->aFunctionIncludeFiles[$mFunction[0]] = $sIncludeFile; |
|
429 | - } |
|
430 | - else { |
|
431 | - $this->aFunctionIncludeFiles[$mFunction] = $sIncludeFile; |
|
432 | - } |
|
433 | - } |
|
434 | - |
|
435 | - /** |
|
436 | - * Registers a PHP function to be called when xajax cannot find the |
|
437 | - * function being called via Javascript. Because this is technically |
|
438 | - * impossible when using "wrapped" functions, the catch-all feature is |
|
439 | - * only useful when you're directly using the xajax.call() Javascript |
|
440 | - * method. Use the catch-all feature when you want more dynamic ability to |
|
441 | - * intercept unknown calls and handle them in a custom way. |
|
442 | - * |
|
443 | - * <i>Usage:</i> <kbd>$xajax->registerCatchAllFunction("myCatchAllFunction");</kbd> |
|
444 | - * |
|
445 | - * @param string contains the function name or an object callback array |
|
446 | - * ({@link xajax::registerFunction() see registerFunction} for |
|
447 | - * more info on object callback arrays) |
|
448 | - */ |
|
449 | - function registerCatchAllFunction($mFunction) |
|
450 | - { |
|
451 | - if (is_array($mFunction)) { |
|
452 | - $this->sCatchAllFunction = $mFunction[0]; |
|
453 | - $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1); |
|
454 | - } |
|
455 | - else { |
|
456 | - $this->sCatchAllFunction = $mFunction; |
|
457 | - } |
|
458 | - } |
|
459 | - |
|
460 | - /** |
|
461 | - * Registers a PHP function to be called before xajax calls the requested |
|
462 | - * function. xajax will automatically add the request function's response |
|
463 | - * to the pre-function's response to create a single response. Another |
|
464 | - * feature is the ability to return not just a response, but an array with |
|
465 | - * the first element being false (a boolean) and the second being the |
|
466 | - * response. In this case, the pre-function's response will be returned to |
|
467 | - * the browser without xajax calling the requested function. |
|
468 | - * |
|
469 | - * <i>Usage:</i> <kbd>$xajax->registerPreFunction("myPreFunction");</kbd> |
|
470 | - * |
|
471 | - * @param string contains the function name or an object callback array |
|
472 | - * ({@link xajax::registerFunction() see registerFunction} for |
|
473 | - * more info on object callback arrays) |
|
474 | - */ |
|
475 | - function registerPreFunction($mFunction) |
|
476 | - { |
|
477 | - if (is_array($mFunction)) { |
|
478 | - $this->sPreFunction = $mFunction[0]; |
|
479 | - $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1); |
|
480 | - } |
|
481 | - else { |
|
482 | - $this->sPreFunction = $mFunction; |
|
483 | - } |
|
484 | - } |
|
485 | - |
|
486 | - /** |
|
487 | - * Returns true if xajax can process the request, false if otherwise. |
|
488 | - * You can use this to determine if xajax needs to process the request or |
|
489 | - * not. |
|
490 | - * |
|
491 | - * @return boolean |
|
492 | - */ |
|
493 | - function canProcessRequests() |
|
494 | - { |
|
495 | - if ($this->getRequestMode() != -1) return true; |
|
496 | - return false; |
|
497 | - } |
|
498 | - |
|
499 | - /** |
|
500 | - * Returns the current request mode (XAJAX_GET or XAJAX_POST), or -1 if |
|
501 | - * there is none. |
|
502 | - * |
|
503 | - * @return mixed |
|
504 | - */ |
|
505 | - function getRequestMode() |
|
506 | - { |
|
507 | - if (!empty($_GET["xajax"])) |
|
508 | - return XAJAX_GET; |
|
509 | - |
|
510 | - if (!empty($_POST["xajax"])) |
|
511 | - return XAJAX_POST; |
|
512 | - |
|
513 | - return -1; |
|
514 | - } |
|
515 | - |
|
516 | - /** |
|
517 | - * This is the main communications engine of xajax. The engine handles all |
|
518 | - * incoming xajax requests, calls the apporiate PHP functions (or |
|
519 | - * class/object methods) and passes the XML responses back to the |
|
520 | - * Javascript response handler. If your RequestURI is the same as your Web |
|
521 | - * page then this function should be called before any headers or HTML has |
|
522 | - * been sent. |
|
523 | - */ |
|
524 | - function processRequests() |
|
525 | - { |
|
526 | - $requestMode = -1; |
|
527 | - $sFunctionName = ""; |
|
528 | - $bFoundFunction = true; |
|
529 | - $bFunctionIsCatchAll = false; |
|
530 | - $sFunctionNameForSpecial = ""; |
|
531 | - $aArgs = array(); |
|
532 | - $sPreResponse = ""; |
|
533 | - $bEndRequest = false; |
|
534 | - $sResponse = ""; |
|
535 | - |
|
536 | - $requestMode = $this->getRequestMode(); |
|
537 | - if ($requestMode == -1) return; |
|
538 | - |
|
539 | - if ($requestMode == XAJAX_POST) |
|
540 | - { |
|
541 | - $sFunctionName = $_POST["xajax"]; |
|
542 | - |
|
543 | - if (!empty($_POST["xajaxargs"])) |
|
544 | - $aArgs = $_POST["xajaxargs"]; |
|
545 | - } |
|
546 | - else |
|
547 | - { |
|
548 | - header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
549 | - header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
550 | - header ("Cache-Control: no-cache, must-revalidate"); |
|
551 | - header ("Pragma: no-cache"); |
|
552 | - |
|
553 | - $sFunctionName = $_GET["xajax"]; |
|
554 | - |
|
555 | - if (!empty($_GET["xajaxargs"])) |
|
556 | - $aArgs = $_GET["xajaxargs"]; |
|
557 | - } |
|
558 | - |
|
559 | - // Use xajax error handler if necessary |
|
560 | - if ($this->bErrorHandler) { |
|
561 | - $GLOBALS['xajaxErrorHandlerText'] = ""; |
|
562 | - set_error_handler("xajaxErrorHandler"); |
|
563 | - } |
|
564 | - |
|
565 | - if ($this->sPreFunction) { |
|
566 | - if (!$this->_isFunctionCallable($this->sPreFunction)) { |
|
567 | - $bFoundFunction = false; |
|
568 | - $objResponse = new xajaxResponse(); |
|
569 | - $objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction); |
|
570 | - $sResponse = $objResponse->getXML(); |
|
571 | - } |
|
572 | - } |
|
573 | - //include any external dependencies associated with this function name |
|
574 | - if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles)) |
|
575 | - { |
|
576 | - ob_start(); |
|
577 | - include_once($this->aFunctionIncludeFiles[$sFunctionName]); |
|
578 | - ob_end_clean(); |
|
579 | - } |
|
580 | - |
|
581 | - if ($bFoundFunction) { |
|
582 | - $sFunctionNameForSpecial = $sFunctionName; |
|
583 | - if (!array_key_exists($sFunctionName, $this->aFunctions)) |
|
584 | - { |
|
585 | - if ($this->sCatchAllFunction) { |
|
586 | - $sFunctionName = $this->sCatchAllFunction; |
|
587 | - $bFunctionIsCatchAll = true; |
|
588 | - } |
|
589 | - else { |
|
590 | - $bFoundFunction = false; |
|
591 | - $objResponse = new xajaxResponse(); |
|
592 | - $objResponse->addAlert("Unknown Function $sFunctionName."); |
|
593 | - $sResponse = $objResponse->getXML(); |
|
594 | - } |
|
595 | - } |
|
596 | - else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode) |
|
597 | - { |
|
598 | - $bFoundFunction = false; |
|
599 | - $objResponse = new xajaxResponse(); |
|
600 | - $objResponse->addAlert("Incorrect Request Type."); |
|
601 | - $sResponse = $objResponse->getXML(); |
|
602 | - } |
|
603 | - } |
|
604 | - |
|
605 | - if ($bFoundFunction) |
|
606 | - { |
|
607 | - for ($i = 0; $i < sizeof($aArgs); $i++) |
|
608 | - { |
|
609 | - // If magic quotes is on, then we need to strip the slashes from the args |
|
610 | - if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) { |
|
611 | - |
|
612 | - $aArgs[$i] = stripslashes($aArgs[$i]); |
|
613 | - } |
|
614 | - if (stristr($aArgs[$i],"<xjxobj>") != false) |
|
615 | - { |
|
616 | - $aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]); |
|
617 | - } |
|
618 | - else if (stristr($aArgs[$i],"<xjxquery>") != false) |
|
619 | - { |
|
620 | - $aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]); |
|
621 | - } |
|
622 | - else if ($this->bDecodeUTF8Input) |
|
623 | - { |
|
624 | - $aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]); |
|
625 | - } |
|
626 | - } |
|
627 | - |
|
628 | - if ($this->sPreFunction) { |
|
629 | - $mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs)); |
|
630 | - if (is_array($mPreResponse) && $mPreResponse[0] === false) { |
|
631 | - $bEndRequest = true; |
|
632 | - $sPreResponse = $mPreResponse[1]; |
|
633 | - } |
|
634 | - else { |
|
635 | - $sPreResponse = $mPreResponse; |
|
636 | - } |
|
637 | - if (is_a($sPreResponse, "xajaxResponse")) { |
|
638 | - $sPreResponse = $sPreResponse->getXML(); |
|
639 | - } |
|
640 | - if ($bEndRequest) $sResponse = $sPreResponse; |
|
641 | - } |
|
642 | - |
|
643 | - if (!$bEndRequest) { |
|
644 | - if (!$this->_isFunctionCallable($sFunctionName)) { |
|
645 | - $objResponse = new xajaxResponse(); |
|
646 | - $objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found."); |
|
647 | - $sResponse = $objResponse->getXML(); |
|
648 | - } |
|
649 | - else { |
|
650 | - if ($bFunctionIsCatchAll) { |
|
651 | - $aArgs = array($sFunctionNameForSpecial, $aArgs); |
|
652 | - } |
|
653 | - $sResponse = $this->_callFunction($sFunctionName, $aArgs); |
|
654 | - } |
|
655 | - if (is_a($sResponse, "xajaxResponse")) { |
|
656 | - $sResponse = $sResponse->getXML(); |
|
657 | - } |
|
658 | - if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) { |
|
659 | - $objResponse = new xajaxResponse(); |
|
660 | - $objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName."); |
|
661 | - $sResponse = $objResponse->getXML(); |
|
662 | - } |
|
663 | - else if ($sPreResponse != "") { |
|
664 | - $sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities); |
|
665 | - $sNewResponse->loadXML($sPreResponse); |
|
666 | - $sNewResponse->loadXML($sResponse); |
|
667 | - $sResponse = $sNewResponse->getXML(); |
|
668 | - } |
|
669 | - } |
|
670 | - } |
|
671 | - |
|
672 | - $sContentHeader = "Content-type: text/xml;"; |
|
673 | - if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
|
674 | - $sContentHeader .= " charset=".$this->sEncoding; |
|
675 | - header($sContentHeader); |
|
676 | - if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) { |
|
677 | - $sErrorResponse = new xajaxResponse(); |
|
678 | - $sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']); |
|
679 | - if ($this->sLogFile) { |
|
680 | - $fH = @fopen($this->sLogFile, "a"); |
|
681 | - if (!$fH) { |
|
682 | - $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile); |
|
683 | - } |
|
684 | - else { |
|
685 | - fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n"); |
|
686 | - fclose($fH); |
|
687 | - } |
|
688 | - } |
|
689 | - |
|
690 | - $sErrorResponse->loadXML($sResponse); |
|
691 | - $sResponse = $sErrorResponse->getXML(); |
|
692 | - |
|
693 | - } |
|
694 | - if ($this->bCleanBuffer) while (@ob_end_clean()); |
|
695 | - print $sResponse; |
|
696 | - if ($this->bErrorHandler) restore_error_handler(); |
|
697 | - |
|
698 | - if ($this->bExitAllowed) |
|
699 | - exit(); |
|
700 | - } |
|
701 | - |
|
702 | - /** |
|
703 | - * Prints the xajax Javascript header and wrapper code into your page by |
|
704 | - * printing the output of the getJavascript() method. It should only be |
|
705 | - * called between the <pre><head> </head></pre> tags in your HTML page. |
|
706 | - * Remember, if you only want to obtain the result of this function, use |
|
707 | - * {@link xajax::getJavascript()} instead. |
|
708 | - * |
|
709 | - * <i>Usage:</i> |
|
710 | - * <code> |
|
711 | - * <head> |
|
712 | - * ... |
|
713 | - * < ?php $xajax->printJavascript(); ? > |
|
714 | - * </code> |
|
715 | - * |
|
716 | - * @param string the relative address of the folder where xajax has been |
|
717 | - * installed. For instance, if your PHP file is |
|
718 | - * "http://www.myserver.com/myfolder/mypage.php" |
|
719 | - * and xajax was installed in |
|
720 | - * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
721 | - * should be set to "../anotherfolder". Defaults to assuming |
|
722 | - * xajax is in the same folder as your PHP file. |
|
723 | - * @param string the relative folder/file pair of the xajax Javascript |
|
724 | - * engine located within the xajax installation folder. |
|
725 | - * Defaults to xajax_js/xajax.js. |
|
726 | - */ |
|
727 | - function printJavascript($sJsURI="", $sJsFile=NULL) |
|
728 | - { |
|
729 | - print $this->getJavascript($sJsURI, $sJsFile); |
|
730 | - } |
|
731 | - |
|
732 | - /** |
|
733 | - * Returns the xajax Javascript code that should be added to your HTML page |
|
734 | - * between the <kbd><head> </head></kbd> tags. |
|
735 | - * |
|
736 | - * <i>Usage:</i> |
|
737 | - * <code> |
|
738 | - * < ?php $xajaxJSHead = $xajax->getJavascript(); ? > |
|
739 | - * <head> |
|
740 | - * ... |
|
741 | - * < ?php echo $xajaxJSHead; ? > |
|
742 | - * </code> |
|
743 | - * |
|
744 | - * @param string the relative address of the folder where xajax has been |
|
745 | - * installed. For instance, if your PHP file is |
|
746 | - * "http://www.myserver.com/myfolder/mypage.php" |
|
747 | - * and xajax was installed in |
|
748 | - * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
749 | - * should be set to "../anotherfolder". Defaults to assuming |
|
750 | - * xajax is in the same folder as your PHP file. |
|
751 | - * @param string the relative folder/file pair of the xajax Javascript |
|
752 | - * engine located within the xajax installation folder. |
|
753 | - * Defaults to xajax_js/xajax.js. |
|
754 | - * @return string |
|
755 | - */ |
|
756 | - function getJavascript($sJsURI="", $sJsFile=NULL) |
|
757 | - { |
|
758 | - $html = $this->getJavascriptConfig(); |
|
759 | - $html .= $this->getJavascriptInclude($sJsURI, $sJsFile); |
|
760 | - |
|
761 | - return $html; |
|
762 | - } |
|
763 | - |
|
764 | - /** |
|
765 | - * Returns a string containing inline Javascript that sets up the xajax |
|
766 | - * runtime (typically called internally by xajax from get/printJavascript). |
|
767 | - * |
|
768 | - * @return string |
|
769 | - */ |
|
770 | - function getJavascriptConfig() |
|
771 | - { |
|
772 | - $html = "\t<script type=\"text/javascript\">\n"; |
|
773 | - $html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n"; |
|
774 | - $html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n"; |
|
775 | - $html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n"; |
|
776 | - $html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n"; |
|
777 | - $html .= "var xajaxDefinedGet=".XAJAX_GET.";\n"; |
|
778 | - $html .= "var xajaxDefinedPost=".XAJAX_POST.";\n"; |
|
779 | - $html .= "var xajaxLoaded=false;\n"; |
|
780 | - |
|
781 | - foreach($this->aFunctions as $sFunction => $bExists) { |
|
782 | - $html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]); |
|
783 | - } |
|
784 | - |
|
785 | - $html .= "\t</script>\n"; |
|
786 | - return $html; |
|
787 | - } |
|
788 | - |
|
789 | - /** |
|
790 | - * Returns a string containing a Javascript include of the xajax.js file |
|
791 | - * along with a check to see if the file loaded after six seconds |
|
792 | - * (typically called internally by xajax from get/printJavascript). |
|
793 | - * |
|
794 | - * @param string the relative address of the folder where xajax has been |
|
795 | - * installed. For instance, if your PHP file is |
|
796 | - * "http://www.myserver.com/myfolder/mypage.php" |
|
797 | - * and xajax was installed in |
|
798 | - * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
799 | - * should be set to "../anotherfolder". Defaults to assuming |
|
800 | - * xajax is in the same folder as your PHP file. |
|
801 | - * @param string the relative folder/file pair of the xajax Javascript |
|
802 | - * engine located within the xajax installation folder. |
|
803 | - * Defaults to xajax_js/xajax.js. |
|
804 | - * @return string |
|
805 | - */ |
|
806 | - function getJavascriptInclude($sJsURI="", $sJsFile=NULL) |
|
807 | - { |
|
808 | - if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js"; |
|
809 | - |
|
810 | - if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/"; |
|
811 | - |
|
812 | - $html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n"; |
|
813 | - $html .= "\t<script type=\"text/javascript\">\n"; |
|
814 | - $html .= "window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\\nURL: {$sJsURI}{$sJsFile}'); } }, 6000);\n"; |
|
815 | - $html .= "\t</script>\n"; |
|
816 | - return $html; |
|
817 | - } |
|
818 | - |
|
819 | - /** |
|
820 | - * This method can be used to create a new xajax.js file out of the |
|
821 | - * xajax_uncompressed.js file (which will only happen if xajax.js doesn't |
|
822 | - * already exist on the filesystem). |
|
823 | - * |
|
824 | - * @param string an optional argument containing the full server file path |
|
825 | - * of xajax.js. |
|
826 | - */ |
|
827 | - function autoCompressJavascript($sJsFullFilename=NULL) |
|
828 | - { |
|
829 | - $sJsFile = "xajax_js/xajax.js"; |
|
830 | - |
|
831 | - if ($sJsFullFilename) { |
|
832 | - $realJsFile = $sJsFullFilename; |
|
833 | - } |
|
834 | - else { |
|
835 | - $realPath = realpath(dirname(__FILE__)); |
|
836 | - $realJsFile = $realPath . "/". $sJsFile; |
|
837 | - } |
|
838 | - |
|
839 | - // Create a compressed file if necessary |
|
840 | - if (!file_exists($realJsFile)) { |
|
841 | - $srcFile = str_replace(".js", "_uncompressed.js", $realJsFile); |
|
842 | - if (!file_exists($srcFile)) { |
|
843 | - trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR); |
|
844 | - } |
|
845 | - require(dirname(__FILE__)."/xajaxCompress.php"); |
|
846 | - $javaScript = implode('', file($srcFile)); |
|
847 | - $compressedScript = xajaxCompressJavascript($javaScript); |
|
848 | - $fH = @fopen($realJsFile, "w"); |
|
849 | - if (!$fH) { |
|
850 | - trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR); |
|
851 | - } |
|
852 | - else { |
|
853 | - fwrite($fH, $compressedScript); |
|
854 | - fclose($fH); |
|
855 | - } |
|
856 | - } |
|
857 | - } |
|
858 | - |
|
859 | - /** |
|
860 | - * Returns the current URL based upon the SERVER vars. |
|
861 | - * |
|
862 | - * @access private |
|
863 | - * @return string |
|
864 | - */ |
|
865 | - function _detectURI() { |
|
866 | - $aURL = array(); |
|
867 | - |
|
868 | - // Try to get the request URL |
|
869 | - if (!empty($_SERVER['REQUEST_URI'])) { |
|
870 | - $aURL = parse_url($_SERVER['REQUEST_URI']); |
|
871 | - } |
|
872 | - |
|
873 | - // Fill in the empty values |
|
874 | - if (empty($aURL['scheme'])) { |
|
875 | - if (!empty($_SERVER['HTTP_SCHEME'])) { |
|
876 | - $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
|
877 | - } else { |
|
878 | - $aURL['scheme'] = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http'; |
|
879 | - } |
|
880 | - } |
|
881 | - |
|
882 | - if (empty($aURL['host'])) { |
|
883 | - if (!empty($_SERVER['HTTP_HOST'])) { |
|
884 | - if (strpos($_SERVER['HTTP_HOST'], ':') > 0) { |
|
885 | - list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']); |
|
886 | - } else { |
|
887 | - $aURL['host'] = $_SERVER['HTTP_HOST']; |
|
888 | - } |
|
889 | - } else if (!empty($_SERVER['SERVER_NAME'])) { |
|
890 | - $aURL['host'] = $_SERVER['SERVER_NAME']; |
|
891 | - } else { |
|
892 | - print "xajax Error: xajax failed to automatically identify your Request URI."; |
|
893 | - print "Please set the Request URI explicitly when you instantiate the xajax object."; |
|
894 | - exit(); |
|
895 | - } |
|
896 | - } |
|
897 | - |
|
898 | - if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) { |
|
899 | - $aURL['port'] = $_SERVER['SERVER_PORT']; |
|
900 | - } |
|
901 | - |
|
902 | - if (empty($aURL['path'])) { |
|
903 | - if (!empty($_SERVER['PATH_INFO'])) { |
|
904 | - $sPath = parse_url($_SERVER['PATH_INFO']); |
|
905 | - } else { |
|
906 | - $sPath = parse_url(api_get_self()); |
|
907 | - } |
|
908 | - $aURL['path'] = $sPath['path']; |
|
909 | - unset($sPath); |
|
910 | - } |
|
911 | - |
|
912 | - if (!empty($aURL['query'])) { |
|
913 | - $aURL['query'] = '?'.$aURL['query']; |
|
914 | - } |
|
915 | - |
|
916 | - // Build the URL: Start with scheme, user and pass |
|
917 | - $sURL = $aURL['scheme'].'://'; |
|
918 | - if (!empty($aURL['user'])) { |
|
919 | - $sURL.= $aURL['user']; |
|
920 | - if (!empty($aURL['pass'])) { |
|
921 | - $sURL.= ':'.$aURL['pass']; |
|
922 | - } |
|
923 | - $sURL.= '@'; |
|
924 | - } |
|
925 | - |
|
926 | - // Add the host |
|
927 | - $sURL.= $aURL['host']; |
|
928 | - |
|
929 | - // Add the port if needed |
|
930 | - if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) { |
|
931 | - $sURL.= ':'.$aURL['port']; |
|
932 | - } |
|
933 | - |
|
934 | - // Add the path and the query string |
|
935 | - $sURL.= $aURL['path'].@$aURL['query']; |
|
936 | - |
|
937 | - // Clean up |
|
938 | - unset($aURL); |
|
939 | - return $sURL; |
|
940 | - } |
|
941 | - |
|
942 | - /** |
|
943 | - * Returns true if the function name is associated with an object callback, |
|
944 | - * false if not. |
|
945 | - * |
|
946 | - * @param string the name of the function |
|
947 | - * @access private |
|
948 | - * @return boolean |
|
949 | - */ |
|
950 | - function _isObjectCallback($sFunction) |
|
951 | - { |
|
952 | - if (array_key_exists($sFunction, $this->aObjects)) return true; |
|
953 | - return false; |
|
954 | - } |
|
955 | - |
|
956 | - /** |
|
957 | - * Returns true if the function or object callback can be called, false if |
|
958 | - * not. |
|
959 | - * |
|
960 | - * @param string the name of the function |
|
961 | - * @access private |
|
962 | - * @return boolean |
|
963 | - */ |
|
964 | - function _isFunctionCallable($sFunction) |
|
965 | - { |
|
966 | - if ($this->_isObjectCallback($sFunction)) { |
|
967 | - if (is_object($this->aObjects[$sFunction][0])) { |
|
968 | - return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]); |
|
969 | - } |
|
970 | - else { |
|
971 | - return is_callable($this->aObjects[$sFunction]); |
|
972 | - } |
|
973 | - } |
|
974 | - else { |
|
975 | - return function_exists($sFunction); |
|
976 | - } |
|
977 | - } |
|
978 | - |
|
979 | - /** |
|
980 | - * Calls the function, class method, or object method with the supplied |
|
981 | - * arguments. |
|
982 | - * |
|
983 | - * @param string the name of the function |
|
984 | - * @param array arguments to pass to the function |
|
985 | - * @access private |
|
986 | - * @return mixed the output of the called function or method |
|
987 | - */ |
|
988 | - function _callFunction($sFunction, $aArgs) |
|
989 | - { |
|
990 | - if ($this->_isObjectCallback($sFunction)) { |
|
991 | - $mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs); |
|
992 | - } |
|
993 | - else { |
|
994 | - $mReturn = call_user_func_array($sFunction, $aArgs); |
|
995 | - } |
|
996 | - return $mReturn; |
|
997 | - } |
|
998 | - |
|
999 | - /** |
|
1000 | - * Generates the Javascript wrapper for the specified PHP function. |
|
1001 | - * |
|
1002 | - * @param string the name of the function |
|
1003 | - * @param mixed the request type |
|
1004 | - * @access private |
|
1005 | - * @return string |
|
1006 | - */ |
|
1007 | - function _wrap($sFunction,$sRequestType=XAJAX_POST) |
|
1008 | - { |
|
1009 | - $js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n"; |
|
1010 | - return $js; |
|
1011 | - } |
|
1012 | - |
|
1013 | - /** |
|
1014 | - * Takes a string containing xajax xjxobj XML or xjxquery XML and builds an |
|
1015 | - * array representation of it to pass as an argument to the PHP function |
|
1016 | - * being called. |
|
1017 | - * |
|
1018 | - * @param string the root tag of the XML |
|
1019 | - * @param string XML to convert |
|
1020 | - * @access private |
|
1021 | - * @return array |
|
1022 | - */ |
|
1023 | - function _xmlToArray($rootTag, $sXml) |
|
1024 | - { |
|
1025 | - $aArray = array(); |
|
1026 | - $sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml); |
|
1027 | - $sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml); |
|
1028 | - $sXml = str_replace("<e>","<e>|~|",$sXml); |
|
1029 | - $sXml = str_replace("</e>","</e>|~|",$sXml); |
|
1030 | - $sXml = str_replace("<k>","<k>|~|",$sXml); |
|
1031 | - $sXml = str_replace("</k>","|~|</k>|~|",$sXml); |
|
1032 | - $sXml = str_replace("<v>","<v>|~|",$sXml); |
|
1033 | - $sXml = str_replace("</v>","|~|</v>|~|",$sXml); |
|
1034 | - $sXml = str_replace("<q>","<q>|~|",$sXml); |
|
1035 | - $sXml = str_replace("</q>","|~|</q>|~|",$sXml); |
|
1036 | - |
|
1037 | - $this->aObjArray = explode("|~|",$sXml); |
|
1038 | - |
|
1039 | - $this->iPos = 0; |
|
1040 | - $aArray = $this->_parseObjXml($rootTag); |
|
1041 | - |
|
1042 | - return $aArray; |
|
1043 | - } |
|
1044 | - |
|
1045 | - /** |
|
1046 | - * A recursive function that generates an array from the contents of |
|
1047 | - * $this->aObjArray. |
|
1048 | - * |
|
1049 | - * @param string the root tag of the XML |
|
1050 | - * @access private |
|
1051 | - * @return array |
|
1052 | - */ |
|
1053 | - function _parseObjXml($rootTag) |
|
1054 | - { |
|
1055 | - $aArray = array(); |
|
1056 | - |
|
1057 | - if ($rootTag == "xjxobj") |
|
1058 | - { |
|
1059 | - while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>")) |
|
1060 | - { |
|
1061 | - $this->iPos++; |
|
1062 | - if(stristr($this->aObjArray[$this->iPos],"<e>")) |
|
1063 | - { |
|
1064 | - $key = ""; |
|
1065 | - $value = null; |
|
1066 | - |
|
1067 | - $this->iPos++; |
|
1068 | - while(!stristr($this->aObjArray[$this->iPos],"</e>")) |
|
1069 | - { |
|
1070 | - if(stristr($this->aObjArray[$this->iPos],"<k>")) |
|
1071 | - { |
|
1072 | - $this->iPos++; |
|
1073 | - while(!stristr($this->aObjArray[$this->iPos],"</k>")) |
|
1074 | - { |
|
1075 | - $key .= $this->aObjArray[$this->iPos]; |
|
1076 | - $this->iPos++; |
|
1077 | - } |
|
1078 | - } |
|
1079 | - if(stristr($this->aObjArray[$this->iPos],"<v>")) |
|
1080 | - { |
|
1081 | - $this->iPos++; |
|
1082 | - while(!stristr($this->aObjArray[$this->iPos],"</v>")) |
|
1083 | - { |
|
1084 | - if(stristr($this->aObjArray[$this->iPos],"<xjxobj>")) |
|
1085 | - { |
|
1086 | - $value = $this->_parseObjXml("xjxobj"); |
|
1087 | - $this->iPos++; |
|
1088 | - } |
|
1089 | - else |
|
1090 | - { |
|
1091 | - $value .= $this->aObjArray[$this->iPos]; |
|
1092 | - if ($this->bDecodeUTF8Input) |
|
1093 | - { |
|
1094 | - $value = $this->_decodeUTF8Data($value); |
|
1095 | - } |
|
1096 | - } |
|
1097 | - $this->iPos++; |
|
1098 | - } |
|
1099 | - } |
|
1100 | - $this->iPos++; |
|
1101 | - } |
|
1102 | - |
|
1103 | - $aArray[$key]=$value; |
|
1104 | - } |
|
1105 | - } |
|
1106 | - } |
|
1107 | - |
|
1108 | - if ($rootTag == "xjxquery") |
|
1109 | - { |
|
1110 | - $sQuery = ""; |
|
1111 | - $this->iPos++; |
|
1112 | - while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>")) |
|
1113 | - { |
|
1114 | - if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>")) |
|
1115 | - { |
|
1116 | - $this->iPos++; |
|
1117 | - continue; |
|
1118 | - } |
|
1119 | - $sQuery .= $this->aObjArray[$this->iPos]; |
|
1120 | - $this->iPos++; |
|
1121 | - } |
|
1122 | - |
|
1123 | - parse_str($sQuery, $aArray); |
|
1124 | - if ($this->bDecodeUTF8Input) |
|
1125 | - { |
|
1126 | - foreach($aArray as $key => $value) |
|
1127 | - { |
|
1128 | - $aArray[$key] = $this->_decodeUTF8Data($value); |
|
1129 | - } |
|
1130 | - } |
|
1131 | - // If magic quotes is on, then we need to strip the slashes from the |
|
1132 | - // array values because of the parse_str pass which adds slashes |
|
1133 | - if (get_magic_quotes_gpc() == 1) { |
|
1134 | - $newArray = array(); |
|
1135 | - foreach ($aArray as $sKey => $sValue) { |
|
1136 | - if (is_string($sValue)) |
|
1137 | - $newArray[$sKey] = stripslashes($sValue); |
|
1138 | - else |
|
1139 | - $newArray[$sKey] = $sValue; |
|
1140 | - } |
|
1141 | - $aArray = $newArray; |
|
1142 | - } |
|
1143 | - } |
|
1144 | - |
|
1145 | - return $aArray; |
|
1146 | - } |
|
1147 | - |
|
1148 | - /** |
|
1149 | - * Decodes string data from UTF-8 to the current xajax encoding. |
|
1150 | - * |
|
1151 | - * @param string data to convert |
|
1152 | - * @access private |
|
1153 | - * @return string converted data |
|
1154 | - */ |
|
1155 | - function _decodeUTF8Data($sData) |
|
1156 | - { |
|
1157 | - $sValue = $sData; |
|
1158 | - if ($this->bDecodeUTF8Input) |
|
1159 | - { |
|
1160 | - $sFuncToUse = NULL; |
|
1161 | - |
|
1162 | - // An adaptation for the Dokeos LMS, 22-AUG-2009. |
|
1163 | - if (function_exists('api_convert_encoding')) |
|
1164 | - { |
|
1165 | - $sFuncToUse = "api_convert_encoding"; |
|
1166 | - } |
|
1167 | - //if (function_exists('iconv')) |
|
1168 | - elseif (function_exists('iconv')) |
|
1169 | - // |
|
1170 | - { |
|
1171 | - $sFuncToUse = "iconv"; |
|
1172 | - } |
|
1173 | - else if (function_exists('mb_convert_encoding')) |
|
1174 | - { |
|
1175 | - $sFuncToUse = "mb_convert_encoding"; |
|
1176 | - } |
|
1177 | - else if ($this->sEncoding == "ISO-8859-1") |
|
1178 | - { |
|
1179 | - $sFuncToUse = "utf8_decode"; |
|
1180 | - } |
|
1181 | - else |
|
1182 | - { |
|
1183 | - trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE); |
|
1184 | - } |
|
1185 | - |
|
1186 | - if ($sFuncToUse) |
|
1187 | - { |
|
1188 | - if (is_string($sValue)) |
|
1189 | - { |
|
1190 | - if ($sFuncToUse == "iconv") |
|
1191 | - { |
|
1192 | - $sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue); |
|
1193 | - } |
|
1194 | - else if ($sFuncToUse == "mb_convert_encoding") |
|
1195 | - { |
|
1196 | - $sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8"); |
|
1197 | - } |
|
1198 | - // Added code, an adaptation for the Dokeos LMS, 22-AUG-2009. |
|
1199 | - else if ($sFuncToUse == "api_convert_encoding") |
|
1200 | - { |
|
1201 | - $sValue = api_convert_encoding($sValue, $this->sEncoding, "UTF-8"); |
|
1202 | - } |
|
1203 | - // |
|
1204 | - else |
|
1205 | - { |
|
1206 | - $sValue = utf8_decode($sValue); |
|
1207 | - } |
|
1208 | - } |
|
1209 | - } |
|
1210 | - } |
|
1211 | - return $sValue; |
|
1212 | - } |
|
78 | + /** |
|
79 | + * @var array Array of PHP functions that will be callable through javascript wrappers |
|
80 | + */ |
|
81 | + var $aFunctions; |
|
82 | + /** |
|
83 | + * @var array Array of object callbacks that will allow Javascript to call PHP methods (key=function name) |
|
84 | + */ |
|
85 | + var $aObjects; |
|
86 | + /** |
|
87 | + * @var array Array of RequestTypes to be used with each function (key=function name) |
|
88 | + */ |
|
89 | + var $aFunctionRequestTypes; |
|
90 | + /** |
|
91 | + * @var array Array of Include Files for any external functions (key=function name) |
|
92 | + */ |
|
93 | + var $aFunctionIncludeFiles; |
|
94 | + /** |
|
95 | + * @var string Name of the PHP function to call if no callable function was found |
|
96 | + */ |
|
97 | + var $sCatchAllFunction; |
|
98 | + /** |
|
99 | + * @var string Name of the PHP function to call before any other function |
|
100 | + */ |
|
101 | + var $sPreFunction; |
|
102 | + /** |
|
103 | + * @var string The URI for making requests to the xajax object |
|
104 | + */ |
|
105 | + var $sRequestURI; |
|
106 | + /** |
|
107 | + * @var string The prefix to prepend to the javascript wraper function name |
|
108 | + */ |
|
109 | + var $sWrapperPrefix; |
|
110 | + /** |
|
111 | + * @var boolean Show debug messages (default false) |
|
112 | + */ |
|
113 | + var $bDebug; |
|
114 | + /** |
|
115 | + * @var boolean Show messages in the client browser's status bar (default false) |
|
116 | + */ |
|
117 | + var $bStatusMessages; |
|
118 | + /** |
|
119 | + * @var boolean Allow xajax to exit after processing a request (default true) |
|
120 | + */ |
|
121 | + var $bExitAllowed; |
|
122 | + /** |
|
123 | + * @var boolean Use wait cursor in browser (default true) |
|
124 | + */ |
|
125 | + var $bWaitCursor; |
|
126 | + /** |
|
127 | + * @var boolean Use an special xajax error handler so the errors are sent to the browser properly (default false) |
|
128 | + */ |
|
129 | + var $bErrorHandler; |
|
130 | + /** |
|
131 | + * @var string Specify what, if any, file xajax should log errors to (and more information in a future release) |
|
132 | + */ |
|
133 | + var $sLogFile; |
|
134 | + /** |
|
135 | + * @var boolean Clean all output buffers before outputting response (default false) |
|
136 | + */ |
|
137 | + var $bCleanBuffer; |
|
138 | + /** |
|
139 | + * @var string String containing the character encoding used |
|
140 | + */ |
|
141 | + var $sEncoding; |
|
142 | + /** |
|
143 | + * @var boolean Decode input request args from UTF-8 (default false) |
|
144 | + */ |
|
145 | + var $bDecodeUTF8Input; |
|
146 | + /** |
|
147 | + * @var boolean Convert special characters to HTML entities (default false) |
|
148 | + */ |
|
149 | + var $bOutputEntities; |
|
150 | + /** |
|
151 | + * @var array Array for parsing complex objects |
|
152 | + */ |
|
153 | + var $aObjArray; |
|
154 | + /** |
|
155 | + * @var integer Position in $aObjArray |
|
156 | + */ |
|
157 | + var $iPos; |
|
158 | + |
|
159 | + /**#@-*/ |
|
160 | + |
|
161 | + /** |
|
162 | + * Constructor. You can set some extra xajax options right away or use |
|
163 | + * individual methods later to set options. |
|
164 | + * |
|
165 | + * @param string defaults to the current browser URI |
|
166 | + * @param string defaults to "xajax_"; |
|
167 | + * @param string defaults to XAJAX_DEFAULT_CHAR_ENCODING defined above |
|
168 | + * @param boolean defaults to false |
|
169 | + */ |
|
170 | + public function __construct($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false) |
|
171 | + { |
|
172 | + $this->aFunctions = array(); |
|
173 | + $this->aObjects = array(); |
|
174 | + $this->aFunctionIncludeFiles = array(); |
|
175 | + $this->sRequestURI = $sRequestURI; |
|
176 | + if ($this->sRequestURI == "") |
|
177 | + $this->sRequestURI = $this->_detectURI(); |
|
178 | + $this->sWrapperPrefix = $sWrapperPrefix; |
|
179 | + $this->bDebug = $bDebug; |
|
180 | + $this->bStatusMessages = false; |
|
181 | + $this->bWaitCursor = true; |
|
182 | + $this->bExitAllowed = true; |
|
183 | + $this->bErrorHandler = false; |
|
184 | + $this->sLogFile = ""; |
|
185 | + $this->bCleanBuffer = false; |
|
186 | + $this->setCharEncoding($sEncoding); |
|
187 | + $this->bDecodeUTF8Input = false; |
|
188 | + $this->bOutputEntities = false; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Sets the URI to which requests will be made. |
|
193 | + * <i>Usage:</i> <kbd>$xajax->setRequestURI("http://www.xajaxproject.org");</kbd> |
|
194 | + * |
|
195 | + * @param string the URI (can be absolute or relative) of the PHP script |
|
196 | + * that will be accessed when an xajax request occurs |
|
197 | + */ |
|
198 | + function setRequestURI($sRequestURI) |
|
199 | + { |
|
200 | + $this->sRequestURI = $sRequestURI; |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Sets the prefix that will be appended to the Javascript wrapper |
|
205 | + * functions (default is "xajax_"). |
|
206 | + * |
|
207 | + * @param string |
|
208 | + */ |
|
209 | + // |
|
210 | + function setWrapperPrefix($sPrefix) |
|
211 | + { |
|
212 | + $this->sWrapperPrefix = $sPrefix; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Enables debug messages for xajax. |
|
217 | + * */ |
|
218 | + function debugOn() |
|
219 | + { |
|
220 | + $this->bDebug = true; |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * Disables debug messages for xajax (default behavior). |
|
225 | + */ |
|
226 | + function debugOff() |
|
227 | + { |
|
228 | + $this->bDebug = false; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Enables messages in the browser's status bar for xajax. |
|
233 | + */ |
|
234 | + function statusMessagesOn() |
|
235 | + { |
|
236 | + $this->bStatusMessages = true; |
|
237 | + } |
|
238 | + |
|
239 | + /** |
|
240 | + * Disables messages in the browser's status bar for xajax (default behavior). |
|
241 | + */ |
|
242 | + function statusMessagesOff() |
|
243 | + { |
|
244 | + $this->bStatusMessages = false; |
|
245 | + } |
|
246 | + |
|
247 | + /** |
|
248 | + * Enables the wait cursor to be displayed in the browser (default behavior). |
|
249 | + */ |
|
250 | + function waitCursorOn() |
|
251 | + { |
|
252 | + $this->bWaitCursor = true; |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * Disables the wait cursor to be displayed in the browser. |
|
257 | + */ |
|
258 | + function waitCursorOff() |
|
259 | + { |
|
260 | + $this->bWaitCursor = false; |
|
261 | + } |
|
262 | + |
|
263 | + /** |
|
264 | + * Enables xajax to exit immediately after processing a request and |
|
265 | + * sending the response back to the browser (default behavior). |
|
266 | + */ |
|
267 | + function exitAllowedOn() |
|
268 | + { |
|
269 | + $this->bExitAllowed = true; |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * Disables xajax's default behavior of exiting immediately after |
|
274 | + * processing a request and sending the response back to the browser. |
|
275 | + */ |
|
276 | + function exitAllowedOff() |
|
277 | + { |
|
278 | + $this->bExitAllowed = false; |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * Turns on xajax's error handling system so that PHP errors that occur |
|
283 | + * during a request are trapped and pushed to the browser in the form of |
|
284 | + * a Javascript alert. |
|
285 | + */ |
|
286 | + function errorHandlerOn() |
|
287 | + { |
|
288 | + $this->bErrorHandler = true; |
|
289 | + } |
|
290 | + |
|
291 | + /** |
|
292 | + * Turns off xajax's error handling system (default behavior). |
|
293 | + */ |
|
294 | + function errorHandlerOff() |
|
295 | + { |
|
296 | + $this->bErrorHandler = false; |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * Specifies a log file that will be written to by xajax during a request |
|
301 | + * (used only by the error handling system at present). If you don't invoke |
|
302 | + * this method, or you pass in "", then no log file will be written to. |
|
303 | + * <i>Usage:</i> <kbd>$xajax->setLogFile("/xajax_logs/errors.log");</kbd> |
|
304 | + */ |
|
305 | + function setLogFile($sFilename) |
|
306 | + { |
|
307 | + $this->sLogFile = $sFilename; |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * Causes xajax to clean out all output buffers before outputting a |
|
312 | + * response (default behavior). |
|
313 | + */ |
|
314 | + function cleanBufferOn() |
|
315 | + { |
|
316 | + $this->bCleanBuffer = true; |
|
317 | + } |
|
318 | + /** |
|
319 | + * Turns off xajax's output buffer cleaning. |
|
320 | + */ |
|
321 | + function cleanBufferOff() |
|
322 | + { |
|
323 | + $this->bCleanBuffer = false; |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Sets the character encoding for the HTTP output based on |
|
328 | + * <kbd>$sEncoding</kbd>, which is a string containing the character |
|
329 | + * encoding to use. You don't need to use this method normally, since the |
|
330 | + * character encoding for the response gets set automatically based on the |
|
331 | + * <kbd>XAJAX_DEFAULT_CHAR_ENCODING</kbd> constant. |
|
332 | + * <i>Usage:</i> <kbd>$xajax->setCharEncoding("utf-8");</kbd> |
|
333 | + * |
|
334 | + * @param string the encoding type to use (utf-8, iso-8859-1, etc.) |
|
335 | + */ |
|
336 | + function setCharEncoding($sEncoding) |
|
337 | + { |
|
338 | + $this->sEncoding = $sEncoding; |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * Causes xajax to decode the input request args from UTF-8 to the current |
|
343 | + * encoding if possible. Either the iconv or mb_string extension must be |
|
344 | + * present for optimal functionality. |
|
345 | + */ |
|
346 | + function decodeUTF8InputOn() |
|
347 | + { |
|
348 | + $this->bDecodeUTF8Input = true; |
|
349 | + } |
|
350 | + |
|
351 | + /** |
|
352 | + * Turns off decoding the input request args from UTF-8 (default behavior). |
|
353 | + */ |
|
354 | + function decodeUTF8InputOff() |
|
355 | + { |
|
356 | + $this->bDecodeUTF8Input = false; |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * Tells the response object to convert special characters to HTML entities |
|
361 | + * automatically (only works if the mb_string extension is available). |
|
362 | + */ |
|
363 | + function outputEntitiesOn() |
|
364 | + { |
|
365 | + $this->bOutputEntities = true; |
|
366 | + } |
|
367 | + |
|
368 | + /** |
|
369 | + * Tells the response object to output special characters intact. (default |
|
370 | + * behavior). |
|
371 | + */ |
|
372 | + function outputEntitiesOff() |
|
373 | + { |
|
374 | + $this->bOutputEntities = false; |
|
375 | + } |
|
376 | + |
|
377 | + /** |
|
378 | + * Registers a PHP function or method to be callable through xajax in your |
|
379 | + * Javascript. If you want to register a function, pass in the name of that |
|
380 | + * function. If you want to register a static class method, pass in an |
|
381 | + * array like so: |
|
382 | + * <kbd>array("myFunctionName", "myClass", "myMethod")</kbd> |
|
383 | + * For an object instance method, use an object variable for the second |
|
384 | + * array element (and in PHP 4 make sure you put an & before the variable |
|
385 | + * to pass the object by reference). Note: the function name is what you |
|
386 | + * call via Javascript, so it can be anything as long as it doesn't |
|
387 | + * conflict with any other registered function name. |
|
388 | + * |
|
389 | + * <i>Usage:</i> <kbd>$xajax->registerFunction("myFunction");</kbd> |
|
390 | + * or: <kbd>$xajax->registerFunction(array("myFunctionName", &$myObject, "myMethod"));</kbd> |
|
391 | + * |
|
392 | + * @param mixed contains the function name or an object callback array |
|
393 | + * @param mixed request type (XAJAX_GET/XAJAX_POST) that should be used |
|
394 | + * for this function. Defaults to XAJAX_POST. |
|
395 | + */ |
|
396 | + function registerFunction($mFunction,$sRequestType=XAJAX_POST) |
|
397 | + { |
|
398 | + if (is_array($mFunction)) { |
|
399 | + $this->aFunctions[$mFunction[0]] = 1; |
|
400 | + $this->aFunctionRequestTypes[$mFunction[0]] = $sRequestType; |
|
401 | + $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1); |
|
402 | + } |
|
403 | + else { |
|
404 | + $this->aFunctions[$mFunction] = 1; |
|
405 | + $this->aFunctionRequestTypes[$mFunction] = $sRequestType; |
|
406 | + } |
|
407 | + } |
|
408 | + |
|
409 | + /** |
|
410 | + * Registers a PHP function to be callable through xajax which is located |
|
411 | + * in some other file. If the function is requested the external file will |
|
412 | + * be included to define the function before the function is called. |
|
413 | + * |
|
414 | + * <i>Usage:</i> <kbd>$xajax->registerExternalFunction("myFunction","myFunction.inc.php",XAJAX_POST);</kbd> |
|
415 | + * |
|
416 | + * @param string contains the function name or an object callback array |
|
417 | + * ({@link xajax::registerFunction() see registerFunction} for |
|
418 | + * more info on object callback arrays) |
|
419 | + * @param string contains the path and filename of the include file |
|
420 | + * @param mixed the RequestType (XAJAX_GET/XAJAX_POST) that should be used |
|
421 | + * for this function. Defaults to XAJAX_POST. |
|
422 | + */ |
|
423 | + function registerExternalFunction($mFunction,$sIncludeFile,$sRequestType=XAJAX_POST) |
|
424 | + { |
|
425 | + $this->registerFunction($mFunction, $sRequestType); |
|
426 | + |
|
427 | + if (is_array($mFunction)) { |
|
428 | + $this->aFunctionIncludeFiles[$mFunction[0]] = $sIncludeFile; |
|
429 | + } |
|
430 | + else { |
|
431 | + $this->aFunctionIncludeFiles[$mFunction] = $sIncludeFile; |
|
432 | + } |
|
433 | + } |
|
434 | + |
|
435 | + /** |
|
436 | + * Registers a PHP function to be called when xajax cannot find the |
|
437 | + * function being called via Javascript. Because this is technically |
|
438 | + * impossible when using "wrapped" functions, the catch-all feature is |
|
439 | + * only useful when you're directly using the xajax.call() Javascript |
|
440 | + * method. Use the catch-all feature when you want more dynamic ability to |
|
441 | + * intercept unknown calls and handle them in a custom way. |
|
442 | + * |
|
443 | + * <i>Usage:</i> <kbd>$xajax->registerCatchAllFunction("myCatchAllFunction");</kbd> |
|
444 | + * |
|
445 | + * @param string contains the function name or an object callback array |
|
446 | + * ({@link xajax::registerFunction() see registerFunction} for |
|
447 | + * more info on object callback arrays) |
|
448 | + */ |
|
449 | + function registerCatchAllFunction($mFunction) |
|
450 | + { |
|
451 | + if (is_array($mFunction)) { |
|
452 | + $this->sCatchAllFunction = $mFunction[0]; |
|
453 | + $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1); |
|
454 | + } |
|
455 | + else { |
|
456 | + $this->sCatchAllFunction = $mFunction; |
|
457 | + } |
|
458 | + } |
|
459 | + |
|
460 | + /** |
|
461 | + * Registers a PHP function to be called before xajax calls the requested |
|
462 | + * function. xajax will automatically add the request function's response |
|
463 | + * to the pre-function's response to create a single response. Another |
|
464 | + * feature is the ability to return not just a response, but an array with |
|
465 | + * the first element being false (a boolean) and the second being the |
|
466 | + * response. In this case, the pre-function's response will be returned to |
|
467 | + * the browser without xajax calling the requested function. |
|
468 | + * |
|
469 | + * <i>Usage:</i> <kbd>$xajax->registerPreFunction("myPreFunction");</kbd> |
|
470 | + * |
|
471 | + * @param string contains the function name or an object callback array |
|
472 | + * ({@link xajax::registerFunction() see registerFunction} for |
|
473 | + * more info on object callback arrays) |
|
474 | + */ |
|
475 | + function registerPreFunction($mFunction) |
|
476 | + { |
|
477 | + if (is_array($mFunction)) { |
|
478 | + $this->sPreFunction = $mFunction[0]; |
|
479 | + $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1); |
|
480 | + } |
|
481 | + else { |
|
482 | + $this->sPreFunction = $mFunction; |
|
483 | + } |
|
484 | + } |
|
485 | + |
|
486 | + /** |
|
487 | + * Returns true if xajax can process the request, false if otherwise. |
|
488 | + * You can use this to determine if xajax needs to process the request or |
|
489 | + * not. |
|
490 | + * |
|
491 | + * @return boolean |
|
492 | + */ |
|
493 | + function canProcessRequests() |
|
494 | + { |
|
495 | + if ($this->getRequestMode() != -1) return true; |
|
496 | + return false; |
|
497 | + } |
|
498 | + |
|
499 | + /** |
|
500 | + * Returns the current request mode (XAJAX_GET or XAJAX_POST), or -1 if |
|
501 | + * there is none. |
|
502 | + * |
|
503 | + * @return mixed |
|
504 | + */ |
|
505 | + function getRequestMode() |
|
506 | + { |
|
507 | + if (!empty($_GET["xajax"])) |
|
508 | + return XAJAX_GET; |
|
509 | + |
|
510 | + if (!empty($_POST["xajax"])) |
|
511 | + return XAJAX_POST; |
|
512 | + |
|
513 | + return -1; |
|
514 | + } |
|
515 | + |
|
516 | + /** |
|
517 | + * This is the main communications engine of xajax. The engine handles all |
|
518 | + * incoming xajax requests, calls the apporiate PHP functions (or |
|
519 | + * class/object methods) and passes the XML responses back to the |
|
520 | + * Javascript response handler. If your RequestURI is the same as your Web |
|
521 | + * page then this function should be called before any headers or HTML has |
|
522 | + * been sent. |
|
523 | + */ |
|
524 | + function processRequests() |
|
525 | + { |
|
526 | + $requestMode = -1; |
|
527 | + $sFunctionName = ""; |
|
528 | + $bFoundFunction = true; |
|
529 | + $bFunctionIsCatchAll = false; |
|
530 | + $sFunctionNameForSpecial = ""; |
|
531 | + $aArgs = array(); |
|
532 | + $sPreResponse = ""; |
|
533 | + $bEndRequest = false; |
|
534 | + $sResponse = ""; |
|
535 | + |
|
536 | + $requestMode = $this->getRequestMode(); |
|
537 | + if ($requestMode == -1) return; |
|
538 | + |
|
539 | + if ($requestMode == XAJAX_POST) |
|
540 | + { |
|
541 | + $sFunctionName = $_POST["xajax"]; |
|
542 | + |
|
543 | + if (!empty($_POST["xajaxargs"])) |
|
544 | + $aArgs = $_POST["xajaxargs"]; |
|
545 | + } |
|
546 | + else |
|
547 | + { |
|
548 | + header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
549 | + header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
550 | + header ("Cache-Control: no-cache, must-revalidate"); |
|
551 | + header ("Pragma: no-cache"); |
|
552 | + |
|
553 | + $sFunctionName = $_GET["xajax"]; |
|
554 | + |
|
555 | + if (!empty($_GET["xajaxargs"])) |
|
556 | + $aArgs = $_GET["xajaxargs"]; |
|
557 | + } |
|
558 | + |
|
559 | + // Use xajax error handler if necessary |
|
560 | + if ($this->bErrorHandler) { |
|
561 | + $GLOBALS['xajaxErrorHandlerText'] = ""; |
|
562 | + set_error_handler("xajaxErrorHandler"); |
|
563 | + } |
|
564 | + |
|
565 | + if ($this->sPreFunction) { |
|
566 | + if (!$this->_isFunctionCallable($this->sPreFunction)) { |
|
567 | + $bFoundFunction = false; |
|
568 | + $objResponse = new xajaxResponse(); |
|
569 | + $objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction); |
|
570 | + $sResponse = $objResponse->getXML(); |
|
571 | + } |
|
572 | + } |
|
573 | + //include any external dependencies associated with this function name |
|
574 | + if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles)) |
|
575 | + { |
|
576 | + ob_start(); |
|
577 | + include_once($this->aFunctionIncludeFiles[$sFunctionName]); |
|
578 | + ob_end_clean(); |
|
579 | + } |
|
580 | + |
|
581 | + if ($bFoundFunction) { |
|
582 | + $sFunctionNameForSpecial = $sFunctionName; |
|
583 | + if (!array_key_exists($sFunctionName, $this->aFunctions)) |
|
584 | + { |
|
585 | + if ($this->sCatchAllFunction) { |
|
586 | + $sFunctionName = $this->sCatchAllFunction; |
|
587 | + $bFunctionIsCatchAll = true; |
|
588 | + } |
|
589 | + else { |
|
590 | + $bFoundFunction = false; |
|
591 | + $objResponse = new xajaxResponse(); |
|
592 | + $objResponse->addAlert("Unknown Function $sFunctionName."); |
|
593 | + $sResponse = $objResponse->getXML(); |
|
594 | + } |
|
595 | + } |
|
596 | + else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode) |
|
597 | + { |
|
598 | + $bFoundFunction = false; |
|
599 | + $objResponse = new xajaxResponse(); |
|
600 | + $objResponse->addAlert("Incorrect Request Type."); |
|
601 | + $sResponse = $objResponse->getXML(); |
|
602 | + } |
|
603 | + } |
|
604 | + |
|
605 | + if ($bFoundFunction) |
|
606 | + { |
|
607 | + for ($i = 0; $i < sizeof($aArgs); $i++) |
|
608 | + { |
|
609 | + // If magic quotes is on, then we need to strip the slashes from the args |
|
610 | + if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) { |
|
611 | + |
|
612 | + $aArgs[$i] = stripslashes($aArgs[$i]); |
|
613 | + } |
|
614 | + if (stristr($aArgs[$i],"<xjxobj>") != false) |
|
615 | + { |
|
616 | + $aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]); |
|
617 | + } |
|
618 | + else if (stristr($aArgs[$i],"<xjxquery>") != false) |
|
619 | + { |
|
620 | + $aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]); |
|
621 | + } |
|
622 | + else if ($this->bDecodeUTF8Input) |
|
623 | + { |
|
624 | + $aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]); |
|
625 | + } |
|
626 | + } |
|
627 | + |
|
628 | + if ($this->sPreFunction) { |
|
629 | + $mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs)); |
|
630 | + if (is_array($mPreResponse) && $mPreResponse[0] === false) { |
|
631 | + $bEndRequest = true; |
|
632 | + $sPreResponse = $mPreResponse[1]; |
|
633 | + } |
|
634 | + else { |
|
635 | + $sPreResponse = $mPreResponse; |
|
636 | + } |
|
637 | + if (is_a($sPreResponse, "xajaxResponse")) { |
|
638 | + $sPreResponse = $sPreResponse->getXML(); |
|
639 | + } |
|
640 | + if ($bEndRequest) $sResponse = $sPreResponse; |
|
641 | + } |
|
642 | + |
|
643 | + if (!$bEndRequest) { |
|
644 | + if (!$this->_isFunctionCallable($sFunctionName)) { |
|
645 | + $objResponse = new xajaxResponse(); |
|
646 | + $objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found."); |
|
647 | + $sResponse = $objResponse->getXML(); |
|
648 | + } |
|
649 | + else { |
|
650 | + if ($bFunctionIsCatchAll) { |
|
651 | + $aArgs = array($sFunctionNameForSpecial, $aArgs); |
|
652 | + } |
|
653 | + $sResponse = $this->_callFunction($sFunctionName, $aArgs); |
|
654 | + } |
|
655 | + if (is_a($sResponse, "xajaxResponse")) { |
|
656 | + $sResponse = $sResponse->getXML(); |
|
657 | + } |
|
658 | + if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) { |
|
659 | + $objResponse = new xajaxResponse(); |
|
660 | + $objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName."); |
|
661 | + $sResponse = $objResponse->getXML(); |
|
662 | + } |
|
663 | + else if ($sPreResponse != "") { |
|
664 | + $sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities); |
|
665 | + $sNewResponse->loadXML($sPreResponse); |
|
666 | + $sNewResponse->loadXML($sResponse); |
|
667 | + $sResponse = $sNewResponse->getXML(); |
|
668 | + } |
|
669 | + } |
|
670 | + } |
|
671 | + |
|
672 | + $sContentHeader = "Content-type: text/xml;"; |
|
673 | + if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
|
674 | + $sContentHeader .= " charset=".$this->sEncoding; |
|
675 | + header($sContentHeader); |
|
676 | + if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) { |
|
677 | + $sErrorResponse = new xajaxResponse(); |
|
678 | + $sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']); |
|
679 | + if ($this->sLogFile) { |
|
680 | + $fH = @fopen($this->sLogFile, "a"); |
|
681 | + if (!$fH) { |
|
682 | + $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile); |
|
683 | + } |
|
684 | + else { |
|
685 | + fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n"); |
|
686 | + fclose($fH); |
|
687 | + } |
|
688 | + } |
|
689 | + |
|
690 | + $sErrorResponse->loadXML($sResponse); |
|
691 | + $sResponse = $sErrorResponse->getXML(); |
|
692 | + |
|
693 | + } |
|
694 | + if ($this->bCleanBuffer) while (@ob_end_clean()); |
|
695 | + print $sResponse; |
|
696 | + if ($this->bErrorHandler) restore_error_handler(); |
|
697 | + |
|
698 | + if ($this->bExitAllowed) |
|
699 | + exit(); |
|
700 | + } |
|
701 | + |
|
702 | + /** |
|
703 | + * Prints the xajax Javascript header and wrapper code into your page by |
|
704 | + * printing the output of the getJavascript() method. It should only be |
|
705 | + * called between the <pre><head> </head></pre> tags in your HTML page. |
|
706 | + * Remember, if you only want to obtain the result of this function, use |
|
707 | + * {@link xajax::getJavascript()} instead. |
|
708 | + * |
|
709 | + * <i>Usage:</i> |
|
710 | + * <code> |
|
711 | + * <head> |
|
712 | + * ... |
|
713 | + * < ?php $xajax->printJavascript(); ? > |
|
714 | + * </code> |
|
715 | + * |
|
716 | + * @param string the relative address of the folder where xajax has been |
|
717 | + * installed. For instance, if your PHP file is |
|
718 | + * "http://www.myserver.com/myfolder/mypage.php" |
|
719 | + * and xajax was installed in |
|
720 | + * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
721 | + * should be set to "../anotherfolder". Defaults to assuming |
|
722 | + * xajax is in the same folder as your PHP file. |
|
723 | + * @param string the relative folder/file pair of the xajax Javascript |
|
724 | + * engine located within the xajax installation folder. |
|
725 | + * Defaults to xajax_js/xajax.js. |
|
726 | + */ |
|
727 | + function printJavascript($sJsURI="", $sJsFile=NULL) |
|
728 | + { |
|
729 | + print $this->getJavascript($sJsURI, $sJsFile); |
|
730 | + } |
|
731 | + |
|
732 | + /** |
|
733 | + * Returns the xajax Javascript code that should be added to your HTML page |
|
734 | + * between the <kbd><head> </head></kbd> tags. |
|
735 | + * |
|
736 | + * <i>Usage:</i> |
|
737 | + * <code> |
|
738 | + * < ?php $xajaxJSHead = $xajax->getJavascript(); ? > |
|
739 | + * <head> |
|
740 | + * ... |
|
741 | + * < ?php echo $xajaxJSHead; ? > |
|
742 | + * </code> |
|
743 | + * |
|
744 | + * @param string the relative address of the folder where xajax has been |
|
745 | + * installed. For instance, if your PHP file is |
|
746 | + * "http://www.myserver.com/myfolder/mypage.php" |
|
747 | + * and xajax was installed in |
|
748 | + * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
749 | + * should be set to "../anotherfolder". Defaults to assuming |
|
750 | + * xajax is in the same folder as your PHP file. |
|
751 | + * @param string the relative folder/file pair of the xajax Javascript |
|
752 | + * engine located within the xajax installation folder. |
|
753 | + * Defaults to xajax_js/xajax.js. |
|
754 | + * @return string |
|
755 | + */ |
|
756 | + function getJavascript($sJsURI="", $sJsFile=NULL) |
|
757 | + { |
|
758 | + $html = $this->getJavascriptConfig(); |
|
759 | + $html .= $this->getJavascriptInclude($sJsURI, $sJsFile); |
|
760 | + |
|
761 | + return $html; |
|
762 | + } |
|
763 | + |
|
764 | + /** |
|
765 | + * Returns a string containing inline Javascript that sets up the xajax |
|
766 | + * runtime (typically called internally by xajax from get/printJavascript). |
|
767 | + * |
|
768 | + * @return string |
|
769 | + */ |
|
770 | + function getJavascriptConfig() |
|
771 | + { |
|
772 | + $html = "\t<script type=\"text/javascript\">\n"; |
|
773 | + $html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n"; |
|
774 | + $html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n"; |
|
775 | + $html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n"; |
|
776 | + $html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n"; |
|
777 | + $html .= "var xajaxDefinedGet=".XAJAX_GET.";\n"; |
|
778 | + $html .= "var xajaxDefinedPost=".XAJAX_POST.";\n"; |
|
779 | + $html .= "var xajaxLoaded=false;\n"; |
|
780 | + |
|
781 | + foreach($this->aFunctions as $sFunction => $bExists) { |
|
782 | + $html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]); |
|
783 | + } |
|
784 | + |
|
785 | + $html .= "\t</script>\n"; |
|
786 | + return $html; |
|
787 | + } |
|
788 | + |
|
789 | + /** |
|
790 | + * Returns a string containing a Javascript include of the xajax.js file |
|
791 | + * along with a check to see if the file loaded after six seconds |
|
792 | + * (typically called internally by xajax from get/printJavascript). |
|
793 | + * |
|
794 | + * @param string the relative address of the folder where xajax has been |
|
795 | + * installed. For instance, if your PHP file is |
|
796 | + * "http://www.myserver.com/myfolder/mypage.php" |
|
797 | + * and xajax was installed in |
|
798 | + * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
799 | + * should be set to "../anotherfolder". Defaults to assuming |
|
800 | + * xajax is in the same folder as your PHP file. |
|
801 | + * @param string the relative folder/file pair of the xajax Javascript |
|
802 | + * engine located within the xajax installation folder. |
|
803 | + * Defaults to xajax_js/xajax.js. |
|
804 | + * @return string |
|
805 | + */ |
|
806 | + function getJavascriptInclude($sJsURI="", $sJsFile=NULL) |
|
807 | + { |
|
808 | + if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js"; |
|
809 | + |
|
810 | + if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/"; |
|
811 | + |
|
812 | + $html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n"; |
|
813 | + $html .= "\t<script type=\"text/javascript\">\n"; |
|
814 | + $html .= "window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\\nURL: {$sJsURI}{$sJsFile}'); } }, 6000);\n"; |
|
815 | + $html .= "\t</script>\n"; |
|
816 | + return $html; |
|
817 | + } |
|
818 | + |
|
819 | + /** |
|
820 | + * This method can be used to create a new xajax.js file out of the |
|
821 | + * xajax_uncompressed.js file (which will only happen if xajax.js doesn't |
|
822 | + * already exist on the filesystem). |
|
823 | + * |
|
824 | + * @param string an optional argument containing the full server file path |
|
825 | + * of xajax.js. |
|
826 | + */ |
|
827 | + function autoCompressJavascript($sJsFullFilename=NULL) |
|
828 | + { |
|
829 | + $sJsFile = "xajax_js/xajax.js"; |
|
830 | + |
|
831 | + if ($sJsFullFilename) { |
|
832 | + $realJsFile = $sJsFullFilename; |
|
833 | + } |
|
834 | + else { |
|
835 | + $realPath = realpath(dirname(__FILE__)); |
|
836 | + $realJsFile = $realPath . "/". $sJsFile; |
|
837 | + } |
|
838 | + |
|
839 | + // Create a compressed file if necessary |
|
840 | + if (!file_exists($realJsFile)) { |
|
841 | + $srcFile = str_replace(".js", "_uncompressed.js", $realJsFile); |
|
842 | + if (!file_exists($srcFile)) { |
|
843 | + trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR); |
|
844 | + } |
|
845 | + require(dirname(__FILE__)."/xajaxCompress.php"); |
|
846 | + $javaScript = implode('', file($srcFile)); |
|
847 | + $compressedScript = xajaxCompressJavascript($javaScript); |
|
848 | + $fH = @fopen($realJsFile, "w"); |
|
849 | + if (!$fH) { |
|
850 | + trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR); |
|
851 | + } |
|
852 | + else { |
|
853 | + fwrite($fH, $compressedScript); |
|
854 | + fclose($fH); |
|
855 | + } |
|
856 | + } |
|
857 | + } |
|
858 | + |
|
859 | + /** |
|
860 | + * Returns the current URL based upon the SERVER vars. |
|
861 | + * |
|
862 | + * @access private |
|
863 | + * @return string |
|
864 | + */ |
|
865 | + function _detectURI() { |
|
866 | + $aURL = array(); |
|
867 | + |
|
868 | + // Try to get the request URL |
|
869 | + if (!empty($_SERVER['REQUEST_URI'])) { |
|
870 | + $aURL = parse_url($_SERVER['REQUEST_URI']); |
|
871 | + } |
|
872 | + |
|
873 | + // Fill in the empty values |
|
874 | + if (empty($aURL['scheme'])) { |
|
875 | + if (!empty($_SERVER['HTTP_SCHEME'])) { |
|
876 | + $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
|
877 | + } else { |
|
878 | + $aURL['scheme'] = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http'; |
|
879 | + } |
|
880 | + } |
|
881 | + |
|
882 | + if (empty($aURL['host'])) { |
|
883 | + if (!empty($_SERVER['HTTP_HOST'])) { |
|
884 | + if (strpos($_SERVER['HTTP_HOST'], ':') > 0) { |
|
885 | + list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']); |
|
886 | + } else { |
|
887 | + $aURL['host'] = $_SERVER['HTTP_HOST']; |
|
888 | + } |
|
889 | + } else if (!empty($_SERVER['SERVER_NAME'])) { |
|
890 | + $aURL['host'] = $_SERVER['SERVER_NAME']; |
|
891 | + } else { |
|
892 | + print "xajax Error: xajax failed to automatically identify your Request URI."; |
|
893 | + print "Please set the Request URI explicitly when you instantiate the xajax object."; |
|
894 | + exit(); |
|
895 | + } |
|
896 | + } |
|
897 | + |
|
898 | + if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) { |
|
899 | + $aURL['port'] = $_SERVER['SERVER_PORT']; |
|
900 | + } |
|
901 | + |
|
902 | + if (empty($aURL['path'])) { |
|
903 | + if (!empty($_SERVER['PATH_INFO'])) { |
|
904 | + $sPath = parse_url($_SERVER['PATH_INFO']); |
|
905 | + } else { |
|
906 | + $sPath = parse_url(api_get_self()); |
|
907 | + } |
|
908 | + $aURL['path'] = $sPath['path']; |
|
909 | + unset($sPath); |
|
910 | + } |
|
911 | + |
|
912 | + if (!empty($aURL['query'])) { |
|
913 | + $aURL['query'] = '?'.$aURL['query']; |
|
914 | + } |
|
915 | + |
|
916 | + // Build the URL: Start with scheme, user and pass |
|
917 | + $sURL = $aURL['scheme'].'://'; |
|
918 | + if (!empty($aURL['user'])) { |
|
919 | + $sURL.= $aURL['user']; |
|
920 | + if (!empty($aURL['pass'])) { |
|
921 | + $sURL.= ':'.$aURL['pass']; |
|
922 | + } |
|
923 | + $sURL.= '@'; |
|
924 | + } |
|
925 | + |
|
926 | + // Add the host |
|
927 | + $sURL.= $aURL['host']; |
|
928 | + |
|
929 | + // Add the port if needed |
|
930 | + if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) { |
|
931 | + $sURL.= ':'.$aURL['port']; |
|
932 | + } |
|
933 | + |
|
934 | + // Add the path and the query string |
|
935 | + $sURL.= $aURL['path'].@$aURL['query']; |
|
936 | + |
|
937 | + // Clean up |
|
938 | + unset($aURL); |
|
939 | + return $sURL; |
|
940 | + } |
|
941 | + |
|
942 | + /** |
|
943 | + * Returns true if the function name is associated with an object callback, |
|
944 | + * false if not. |
|
945 | + * |
|
946 | + * @param string the name of the function |
|
947 | + * @access private |
|
948 | + * @return boolean |
|
949 | + */ |
|
950 | + function _isObjectCallback($sFunction) |
|
951 | + { |
|
952 | + if (array_key_exists($sFunction, $this->aObjects)) return true; |
|
953 | + return false; |
|
954 | + } |
|
955 | + |
|
956 | + /** |
|
957 | + * Returns true if the function or object callback can be called, false if |
|
958 | + * not. |
|
959 | + * |
|
960 | + * @param string the name of the function |
|
961 | + * @access private |
|
962 | + * @return boolean |
|
963 | + */ |
|
964 | + function _isFunctionCallable($sFunction) |
|
965 | + { |
|
966 | + if ($this->_isObjectCallback($sFunction)) { |
|
967 | + if (is_object($this->aObjects[$sFunction][0])) { |
|
968 | + return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]); |
|
969 | + } |
|
970 | + else { |
|
971 | + return is_callable($this->aObjects[$sFunction]); |
|
972 | + } |
|
973 | + } |
|
974 | + else { |
|
975 | + return function_exists($sFunction); |
|
976 | + } |
|
977 | + } |
|
978 | + |
|
979 | + /** |
|
980 | + * Calls the function, class method, or object method with the supplied |
|
981 | + * arguments. |
|
982 | + * |
|
983 | + * @param string the name of the function |
|
984 | + * @param array arguments to pass to the function |
|
985 | + * @access private |
|
986 | + * @return mixed the output of the called function or method |
|
987 | + */ |
|
988 | + function _callFunction($sFunction, $aArgs) |
|
989 | + { |
|
990 | + if ($this->_isObjectCallback($sFunction)) { |
|
991 | + $mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs); |
|
992 | + } |
|
993 | + else { |
|
994 | + $mReturn = call_user_func_array($sFunction, $aArgs); |
|
995 | + } |
|
996 | + return $mReturn; |
|
997 | + } |
|
998 | + |
|
999 | + /** |
|
1000 | + * Generates the Javascript wrapper for the specified PHP function. |
|
1001 | + * |
|
1002 | + * @param string the name of the function |
|
1003 | + * @param mixed the request type |
|
1004 | + * @access private |
|
1005 | + * @return string |
|
1006 | + */ |
|
1007 | + function _wrap($sFunction,$sRequestType=XAJAX_POST) |
|
1008 | + { |
|
1009 | + $js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n"; |
|
1010 | + return $js; |
|
1011 | + } |
|
1012 | + |
|
1013 | + /** |
|
1014 | + * Takes a string containing xajax xjxobj XML or xjxquery XML and builds an |
|
1015 | + * array representation of it to pass as an argument to the PHP function |
|
1016 | + * being called. |
|
1017 | + * |
|
1018 | + * @param string the root tag of the XML |
|
1019 | + * @param string XML to convert |
|
1020 | + * @access private |
|
1021 | + * @return array |
|
1022 | + */ |
|
1023 | + function _xmlToArray($rootTag, $sXml) |
|
1024 | + { |
|
1025 | + $aArray = array(); |
|
1026 | + $sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml); |
|
1027 | + $sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml); |
|
1028 | + $sXml = str_replace("<e>","<e>|~|",$sXml); |
|
1029 | + $sXml = str_replace("</e>","</e>|~|",$sXml); |
|
1030 | + $sXml = str_replace("<k>","<k>|~|",$sXml); |
|
1031 | + $sXml = str_replace("</k>","|~|</k>|~|",$sXml); |
|
1032 | + $sXml = str_replace("<v>","<v>|~|",$sXml); |
|
1033 | + $sXml = str_replace("</v>","|~|</v>|~|",$sXml); |
|
1034 | + $sXml = str_replace("<q>","<q>|~|",$sXml); |
|
1035 | + $sXml = str_replace("</q>","|~|</q>|~|",$sXml); |
|
1036 | + |
|
1037 | + $this->aObjArray = explode("|~|",$sXml); |
|
1038 | + |
|
1039 | + $this->iPos = 0; |
|
1040 | + $aArray = $this->_parseObjXml($rootTag); |
|
1041 | + |
|
1042 | + return $aArray; |
|
1043 | + } |
|
1044 | + |
|
1045 | + /** |
|
1046 | + * A recursive function that generates an array from the contents of |
|
1047 | + * $this->aObjArray. |
|
1048 | + * |
|
1049 | + * @param string the root tag of the XML |
|
1050 | + * @access private |
|
1051 | + * @return array |
|
1052 | + */ |
|
1053 | + function _parseObjXml($rootTag) |
|
1054 | + { |
|
1055 | + $aArray = array(); |
|
1056 | + |
|
1057 | + if ($rootTag == "xjxobj") |
|
1058 | + { |
|
1059 | + while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>")) |
|
1060 | + { |
|
1061 | + $this->iPos++; |
|
1062 | + if(stristr($this->aObjArray[$this->iPos],"<e>")) |
|
1063 | + { |
|
1064 | + $key = ""; |
|
1065 | + $value = null; |
|
1066 | + |
|
1067 | + $this->iPos++; |
|
1068 | + while(!stristr($this->aObjArray[$this->iPos],"</e>")) |
|
1069 | + { |
|
1070 | + if(stristr($this->aObjArray[$this->iPos],"<k>")) |
|
1071 | + { |
|
1072 | + $this->iPos++; |
|
1073 | + while(!stristr($this->aObjArray[$this->iPos],"</k>")) |
|
1074 | + { |
|
1075 | + $key .= $this->aObjArray[$this->iPos]; |
|
1076 | + $this->iPos++; |
|
1077 | + } |
|
1078 | + } |
|
1079 | + if(stristr($this->aObjArray[$this->iPos],"<v>")) |
|
1080 | + { |
|
1081 | + $this->iPos++; |
|
1082 | + while(!stristr($this->aObjArray[$this->iPos],"</v>")) |
|
1083 | + { |
|
1084 | + if(stristr($this->aObjArray[$this->iPos],"<xjxobj>")) |
|
1085 | + { |
|
1086 | + $value = $this->_parseObjXml("xjxobj"); |
|
1087 | + $this->iPos++; |
|
1088 | + } |
|
1089 | + else |
|
1090 | + { |
|
1091 | + $value .= $this->aObjArray[$this->iPos]; |
|
1092 | + if ($this->bDecodeUTF8Input) |
|
1093 | + { |
|
1094 | + $value = $this->_decodeUTF8Data($value); |
|
1095 | + } |
|
1096 | + } |
|
1097 | + $this->iPos++; |
|
1098 | + } |
|
1099 | + } |
|
1100 | + $this->iPos++; |
|
1101 | + } |
|
1102 | + |
|
1103 | + $aArray[$key]=$value; |
|
1104 | + } |
|
1105 | + } |
|
1106 | + } |
|
1107 | + |
|
1108 | + if ($rootTag == "xjxquery") |
|
1109 | + { |
|
1110 | + $sQuery = ""; |
|
1111 | + $this->iPos++; |
|
1112 | + while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>")) |
|
1113 | + { |
|
1114 | + if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>")) |
|
1115 | + { |
|
1116 | + $this->iPos++; |
|
1117 | + continue; |
|
1118 | + } |
|
1119 | + $sQuery .= $this->aObjArray[$this->iPos]; |
|
1120 | + $this->iPos++; |
|
1121 | + } |
|
1122 | + |
|
1123 | + parse_str($sQuery, $aArray); |
|
1124 | + if ($this->bDecodeUTF8Input) |
|
1125 | + { |
|
1126 | + foreach($aArray as $key => $value) |
|
1127 | + { |
|
1128 | + $aArray[$key] = $this->_decodeUTF8Data($value); |
|
1129 | + } |
|
1130 | + } |
|
1131 | + // If magic quotes is on, then we need to strip the slashes from the |
|
1132 | + // array values because of the parse_str pass which adds slashes |
|
1133 | + if (get_magic_quotes_gpc() == 1) { |
|
1134 | + $newArray = array(); |
|
1135 | + foreach ($aArray as $sKey => $sValue) { |
|
1136 | + if (is_string($sValue)) |
|
1137 | + $newArray[$sKey] = stripslashes($sValue); |
|
1138 | + else |
|
1139 | + $newArray[$sKey] = $sValue; |
|
1140 | + } |
|
1141 | + $aArray = $newArray; |
|
1142 | + } |
|
1143 | + } |
|
1144 | + |
|
1145 | + return $aArray; |
|
1146 | + } |
|
1147 | + |
|
1148 | + /** |
|
1149 | + * Decodes string data from UTF-8 to the current xajax encoding. |
|
1150 | + * |
|
1151 | + * @param string data to convert |
|
1152 | + * @access private |
|
1153 | + * @return string converted data |
|
1154 | + */ |
|
1155 | + function _decodeUTF8Data($sData) |
|
1156 | + { |
|
1157 | + $sValue = $sData; |
|
1158 | + if ($this->bDecodeUTF8Input) |
|
1159 | + { |
|
1160 | + $sFuncToUse = NULL; |
|
1161 | + |
|
1162 | + // An adaptation for the Dokeos LMS, 22-AUG-2009. |
|
1163 | + if (function_exists('api_convert_encoding')) |
|
1164 | + { |
|
1165 | + $sFuncToUse = "api_convert_encoding"; |
|
1166 | + } |
|
1167 | + //if (function_exists('iconv')) |
|
1168 | + elseif (function_exists('iconv')) |
|
1169 | + // |
|
1170 | + { |
|
1171 | + $sFuncToUse = "iconv"; |
|
1172 | + } |
|
1173 | + else if (function_exists('mb_convert_encoding')) |
|
1174 | + { |
|
1175 | + $sFuncToUse = "mb_convert_encoding"; |
|
1176 | + } |
|
1177 | + else if ($this->sEncoding == "ISO-8859-1") |
|
1178 | + { |
|
1179 | + $sFuncToUse = "utf8_decode"; |
|
1180 | + } |
|
1181 | + else |
|
1182 | + { |
|
1183 | + trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE); |
|
1184 | + } |
|
1185 | + |
|
1186 | + if ($sFuncToUse) |
|
1187 | + { |
|
1188 | + if (is_string($sValue)) |
|
1189 | + { |
|
1190 | + if ($sFuncToUse == "iconv") |
|
1191 | + { |
|
1192 | + $sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue); |
|
1193 | + } |
|
1194 | + else if ($sFuncToUse == "mb_convert_encoding") |
|
1195 | + { |
|
1196 | + $sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8"); |
|
1197 | + } |
|
1198 | + // Added code, an adaptation for the Dokeos LMS, 22-AUG-2009. |
|
1199 | + else if ($sFuncToUse == "api_convert_encoding") |
|
1200 | + { |
|
1201 | + $sValue = api_convert_encoding($sValue, $this->sEncoding, "UTF-8"); |
|
1202 | + } |
|
1203 | + // |
|
1204 | + else |
|
1205 | + { |
|
1206 | + $sValue = utf8_decode($sValue); |
|
1207 | + } |
|
1208 | + } |
|
1209 | + } |
|
1210 | + } |
|
1211 | + return $sValue; |
|
1212 | + } |
|
1213 | 1213 | |
1214 | 1214 | }// end class xajax |
1215 | 1215 | |
@@ -1219,31 +1219,31 @@ discard block |
||
1219 | 1219 | */ |
1220 | 1220 | function xajaxErrorHandler($errno, $errstr, $errfile, $errline) |
1221 | 1221 | { |
1222 | - $errorReporting = error_reporting(); |
|
1223 | - if (($errno & $errorReporting) == 0) return; |
|
1224 | - |
|
1225 | - if ($errno == E_NOTICE) { |
|
1226 | - $errTypeStr = "NOTICE"; |
|
1227 | - } |
|
1228 | - else if ($errno == E_WARNING) { |
|
1229 | - $errTypeStr = "WARNING"; |
|
1230 | - } |
|
1231 | - else if ($errno == E_USER_NOTICE) { |
|
1232 | - $errTypeStr = "USER NOTICE"; |
|
1233 | - } |
|
1234 | - else if ($errno == E_USER_WARNING) { |
|
1235 | - $errTypeStr = "USER WARNING"; |
|
1236 | - } |
|
1237 | - else if ($errno == E_USER_ERROR) { |
|
1238 | - $errTypeStr = "USER FATAL ERROR"; |
|
1239 | - } |
|
1240 | - else if ($errno == E_STRICT) { |
|
1241 | - return; |
|
1242 | - } |
|
1243 | - else { |
|
1244 | - $errTypeStr = "UNKNOWN: $errno"; |
|
1245 | - } |
|
1246 | - $GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile"; |
|
1222 | + $errorReporting = error_reporting(); |
|
1223 | + if (($errno & $errorReporting) == 0) return; |
|
1224 | + |
|
1225 | + if ($errno == E_NOTICE) { |
|
1226 | + $errTypeStr = "NOTICE"; |
|
1227 | + } |
|
1228 | + else if ($errno == E_WARNING) { |
|
1229 | + $errTypeStr = "WARNING"; |
|
1230 | + } |
|
1231 | + else if ($errno == E_USER_NOTICE) { |
|
1232 | + $errTypeStr = "USER NOTICE"; |
|
1233 | + } |
|
1234 | + else if ($errno == E_USER_WARNING) { |
|
1235 | + $errTypeStr = "USER WARNING"; |
|
1236 | + } |
|
1237 | + else if ($errno == E_USER_ERROR) { |
|
1238 | + $errTypeStr = "USER FATAL ERROR"; |
|
1239 | + } |
|
1240 | + else if ($errno == E_STRICT) { |
|
1241 | + return; |
|
1242 | + } |
|
1243 | + else { |
|
1244 | + $errTypeStr = "UNKNOWN: $errno"; |
|
1245 | + } |
|
1246 | + $GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile"; |
|
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | ?> |
@@ -39,6 +39,7 @@ |
||
39 | 39 | * (used internally) |
40 | 40 | * |
41 | 41 | * @param string contains the Javascript code to compress |
42 | + * @param string $sJS |
|
42 | 43 | */ |
43 | 44 | function xajaxCompressJavascript($sJS) |
44 | 45 | { |
@@ -42,141 +42,141 @@ |
||
42 | 42 | */ |
43 | 43 | function xajaxCompressJavascript($sJS) |
44 | 44 | { |
45 | - //remove windows cariage returns |
|
46 | - $sJS = str_replace("\r","",$sJS); |
|
47 | - |
|
48 | - //array to store replaced literal strings |
|
49 | - $literal_strings = array(); |
|
50 | - |
|
51 | - //explode the string into lines |
|
52 | - $lines = explode("\n",$sJS); |
|
53 | - //loop through all the lines, building a new string at the same time as removing literal strings |
|
54 | - $clean = ""; |
|
55 | - $inComment = false; |
|
56 | - $literal = ""; |
|
57 | - $inQuote = false; |
|
58 | - $escaped = false; |
|
59 | - $quoteChar = ""; |
|
60 | - |
|
61 | - for($i=0;$i<count($lines);$i++) |
|
62 | - { |
|
63 | - $line = $lines[$i]; |
|
64 | - $inNormalComment = false; |
|
65 | - |
|
66 | - //loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string |
|
67 | - for($j=0;$j<strlen($line);$j++) |
|
68 | - { |
|
69 | - $c = substr($line,$j,1); |
|
70 | - $d = substr($line,$j,2); |
|
71 | - |
|
72 | - //look for start of quote |
|
73 | - if(!$inQuote && !$inComment) |
|
74 | - { |
|
75 | - //is this character a quote or a comment |
|
76 | - if(($c=="\"" || $c=="'") && !$inComment && !$inNormalComment) |
|
77 | - { |
|
78 | - $inQuote = true; |
|
79 | - $inComment = false; |
|
80 | - $escaped = false; |
|
81 | - $quoteChar = $c; |
|
82 | - $literal = $c; |
|
83 | - } |
|
84 | - else if($d=="/*" && !$inNormalComment) |
|
85 | - { |
|
86 | - $inQuote = false; |
|
87 | - $inComment = true; |
|
88 | - $escaped = false; |
|
89 | - $quoteChar = $d; |
|
90 | - $literal = $d; |
|
91 | - $j++; |
|
92 | - } |
|
93 | - else if($d=="//") //ignore string markers that are found inside comments |
|
94 | - { |
|
95 | - $inNormalComment = true; |
|
96 | - $clean .= $c; |
|
97 | - } |
|
98 | - else |
|
99 | - { |
|
100 | - $clean .= $c; |
|
101 | - } |
|
102 | - } |
|
103 | - else //allready in a string so find end quote |
|
104 | - { |
|
105 | - if($c == $quoteChar && !$escaped && !$inComment) |
|
106 | - { |
|
107 | - $inQuote = false; |
|
108 | - $literal .= $c; |
|
109 | - |
|
110 | - //subsitute in a marker for the string |
|
111 | - $clean .= "___" . count($literal_strings) . "___"; |
|
112 | - |
|
113 | - //push the string onto our array |
|
114 | - array_push($literal_strings,$literal); |
|
115 | - |
|
116 | - } |
|
117 | - else if($inComment && $d=="*/") |
|
118 | - { |
|
119 | - $inComment = false; |
|
120 | - $literal .= $d; |
|
121 | - |
|
122 | - //subsitute in a marker for the string |
|
123 | - $clean .= "___" . count($literal_strings) . "___"; |
|
124 | - |
|
125 | - //push the string onto our array |
|
126 | - array_push($literal_strings,$literal); |
|
127 | - |
|
128 | - $j++; |
|
129 | - } |
|
130 | - else if($c == "\\" && !$escaped) |
|
131 | - $escaped = true; |
|
132 | - else |
|
133 | - $escaped = false; |
|
134 | - |
|
135 | - $literal .= $c; |
|
136 | - } |
|
137 | - } |
|
138 | - if($inComment) $literal .= "\n"; |
|
139 | - $clean .= "\n"; |
|
140 | - } |
|
141 | - //explode the clean string into lines again |
|
142 | - $lines = explode("\n",$clean); |
|
143 | - |
|
144 | - //now process each line at a time |
|
145 | - for($i=0;$i<count($lines);$i++) |
|
146 | - { |
|
147 | - $line = $lines[$i]; |
|
148 | - |
|
149 | - //remove comments |
|
150 | - $line = preg_replace("/\/\/(.*)/","",$line); |
|
151 | - |
|
152 | - //strip leading and trailing whitespace |
|
153 | - $line = trim($line); |
|
154 | - |
|
155 | - //remove all whitespace with a single space |
|
156 | - $line = preg_replace("/\s+/"," ",$line); |
|
157 | - |
|
158 | - //remove any whitespace that occurs after/before an operator |
|
159 | - $line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line); |
|
160 | - |
|
161 | - $lines[$i] = $line; |
|
162 | - } |
|
163 | - |
|
164 | - //implode the lines |
|
165 | - $sJS = implode("\n",$lines); |
|
166 | - |
|
167 | - //make sure there is a max of 1 \n after each line |
|
168 | - $sJS = preg_replace("/[\n]+/","\n",$sJS); |
|
169 | - |
|
170 | - //strip out line breaks that immediately follow a semi-colon |
|
171 | - $sJS = preg_replace("/;\n/",";",$sJS); |
|
172 | - |
|
173 | - //curly brackets aren't on their own |
|
174 | - $sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS); |
|
175 | - |
|
176 | - //finally loop through and replace all the literal strings: |
|
177 | - for($i=0;$i<count($literal_strings);$i++) |
|
178 | - $sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS); |
|
179 | - |
|
180 | - return $sJS; |
|
45 | + //remove windows cariage returns |
|
46 | + $sJS = str_replace("\r","",$sJS); |
|
47 | + |
|
48 | + //array to store replaced literal strings |
|
49 | + $literal_strings = array(); |
|
50 | + |
|
51 | + //explode the string into lines |
|
52 | + $lines = explode("\n",$sJS); |
|
53 | + //loop through all the lines, building a new string at the same time as removing literal strings |
|
54 | + $clean = ""; |
|
55 | + $inComment = false; |
|
56 | + $literal = ""; |
|
57 | + $inQuote = false; |
|
58 | + $escaped = false; |
|
59 | + $quoteChar = ""; |
|
60 | + |
|
61 | + for($i=0;$i<count($lines);$i++) |
|
62 | + { |
|
63 | + $line = $lines[$i]; |
|
64 | + $inNormalComment = false; |
|
65 | + |
|
66 | + //loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string |
|
67 | + for($j=0;$j<strlen($line);$j++) |
|
68 | + { |
|
69 | + $c = substr($line,$j,1); |
|
70 | + $d = substr($line,$j,2); |
|
71 | + |
|
72 | + //look for start of quote |
|
73 | + if(!$inQuote && !$inComment) |
|
74 | + { |
|
75 | + //is this character a quote or a comment |
|
76 | + if(($c=="\"" || $c=="'") && !$inComment && !$inNormalComment) |
|
77 | + { |
|
78 | + $inQuote = true; |
|
79 | + $inComment = false; |
|
80 | + $escaped = false; |
|
81 | + $quoteChar = $c; |
|
82 | + $literal = $c; |
|
83 | + } |
|
84 | + else if($d=="/*" && !$inNormalComment) |
|
85 | + { |
|
86 | + $inQuote = false; |
|
87 | + $inComment = true; |
|
88 | + $escaped = false; |
|
89 | + $quoteChar = $d; |
|
90 | + $literal = $d; |
|
91 | + $j++; |
|
92 | + } |
|
93 | + else if($d=="//") //ignore string markers that are found inside comments |
|
94 | + { |
|
95 | + $inNormalComment = true; |
|
96 | + $clean .= $c; |
|
97 | + } |
|
98 | + else |
|
99 | + { |
|
100 | + $clean .= $c; |
|
101 | + } |
|
102 | + } |
|
103 | + else //allready in a string so find end quote |
|
104 | + { |
|
105 | + if($c == $quoteChar && !$escaped && !$inComment) |
|
106 | + { |
|
107 | + $inQuote = false; |
|
108 | + $literal .= $c; |
|
109 | + |
|
110 | + //subsitute in a marker for the string |
|
111 | + $clean .= "___" . count($literal_strings) . "___"; |
|
112 | + |
|
113 | + //push the string onto our array |
|
114 | + array_push($literal_strings,$literal); |
|
115 | + |
|
116 | + } |
|
117 | + else if($inComment && $d=="*/") |
|
118 | + { |
|
119 | + $inComment = false; |
|
120 | + $literal .= $d; |
|
121 | + |
|
122 | + //subsitute in a marker for the string |
|
123 | + $clean .= "___" . count($literal_strings) . "___"; |
|
124 | + |
|
125 | + //push the string onto our array |
|
126 | + array_push($literal_strings,$literal); |
|
127 | + |
|
128 | + $j++; |
|
129 | + } |
|
130 | + else if($c == "\\" && !$escaped) |
|
131 | + $escaped = true; |
|
132 | + else |
|
133 | + $escaped = false; |
|
134 | + |
|
135 | + $literal .= $c; |
|
136 | + } |
|
137 | + } |
|
138 | + if($inComment) $literal .= "\n"; |
|
139 | + $clean .= "\n"; |
|
140 | + } |
|
141 | + //explode the clean string into lines again |
|
142 | + $lines = explode("\n",$clean); |
|
143 | + |
|
144 | + //now process each line at a time |
|
145 | + for($i=0;$i<count($lines);$i++) |
|
146 | + { |
|
147 | + $line = $lines[$i]; |
|
148 | + |
|
149 | + //remove comments |
|
150 | + $line = preg_replace("/\/\/(.*)/","",$line); |
|
151 | + |
|
152 | + //strip leading and trailing whitespace |
|
153 | + $line = trim($line); |
|
154 | + |
|
155 | + //remove all whitespace with a single space |
|
156 | + $line = preg_replace("/\s+/"," ",$line); |
|
157 | + |
|
158 | + //remove any whitespace that occurs after/before an operator |
|
159 | + $line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line); |
|
160 | + |
|
161 | + $lines[$i] = $line; |
|
162 | + } |
|
163 | + |
|
164 | + //implode the lines |
|
165 | + $sJS = implode("\n",$lines); |
|
166 | + |
|
167 | + //make sure there is a max of 1 \n after each line |
|
168 | + $sJS = preg_replace("/[\n]+/","\n",$sJS); |
|
169 | + |
|
170 | + //strip out line breaks that immediately follow a semi-colon |
|
171 | + $sJS = preg_replace("/;\n/",";",$sJS); |
|
172 | + |
|
173 | + //curly brackets aren't on their own |
|
174 | + $sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS); |
|
175 | + |
|
176 | + //finally loop through and replace all the literal strings: |
|
177 | + for($i=0;$i<count($literal_strings);$i++) |
|
178 | + $sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS); |
|
179 | + |
|
180 | + return $sJS; |
|
181 | 181 | } |
182 | 182 | ?> |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | function xajaxCompressJavascript($sJS) |
44 | 44 | { |
45 | 45 | //remove windows cariage returns |
46 | - $sJS = str_replace("\r","",$sJS); |
|
46 | + $sJS = str_replace("\r", "", $sJS); |
|
47 | 47 | |
48 | 48 | //array to store replaced literal strings |
49 | 49 | $literal_strings = array(); |
50 | 50 | |
51 | 51 | //explode the string into lines |
52 | - $lines = explode("\n",$sJS); |
|
52 | + $lines = explode("\n", $sJS); |
|
53 | 53 | //loop through all the lines, building a new string at the same time as removing literal strings |
54 | 54 | $clean = ""; |
55 | 55 | $inComment = false; |
@@ -58,22 +58,22 @@ discard block |
||
58 | 58 | $escaped = false; |
59 | 59 | $quoteChar = ""; |
60 | 60 | |
61 | - for($i=0;$i<count($lines);$i++) |
|
61 | + for ($i = 0; $i < count($lines); $i++) |
|
62 | 62 | { |
63 | 63 | $line = $lines[$i]; |
64 | 64 | $inNormalComment = false; |
65 | 65 | |
66 | 66 | //loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string |
67 | - for($j=0;$j<strlen($line);$j++) |
|
67 | + for ($j = 0; $j < strlen($line); $j++) |
|
68 | 68 | { |
69 | - $c = substr($line,$j,1); |
|
70 | - $d = substr($line,$j,2); |
|
69 | + $c = substr($line, $j, 1); |
|
70 | + $d = substr($line, $j, 2); |
|
71 | 71 | |
72 | 72 | //look for start of quote |
73 | - if(!$inQuote && !$inComment) |
|
73 | + if (!$inQuote && !$inComment) |
|
74 | 74 | { |
75 | 75 | //is this character a quote or a comment |
76 | - if(($c=="\"" || $c=="'") && !$inComment && !$inNormalComment) |
|
76 | + if (($c == "\"" || $c == "'") && !$inComment && !$inNormalComment) |
|
77 | 77 | { |
78 | 78 | $inQuote = true; |
79 | 79 | $inComment = false; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $quoteChar = $c; |
82 | 82 | $literal = $c; |
83 | 83 | } |
84 | - else if($d=="/*" && !$inNormalComment) |
|
84 | + else if ($d == "/*" && !$inNormalComment) |
|
85 | 85 | { |
86 | 86 | $inQuote = false; |
87 | 87 | $inComment = true; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $literal = $d; |
91 | 91 | $j++; |
92 | 92 | } |
93 | - else if($d=="//") //ignore string markers that are found inside comments |
|
93 | + else if ($d == "//") //ignore string markers that are found inside comments |
|
94 | 94 | { |
95 | 95 | $inNormalComment = true; |
96 | 96 | $clean .= $c; |
@@ -102,32 +102,32 @@ discard block |
||
102 | 102 | } |
103 | 103 | else //allready in a string so find end quote |
104 | 104 | { |
105 | - if($c == $quoteChar && !$escaped && !$inComment) |
|
105 | + if ($c == $quoteChar && !$escaped && !$inComment) |
|
106 | 106 | { |
107 | 107 | $inQuote = false; |
108 | 108 | $literal .= $c; |
109 | 109 | |
110 | 110 | //subsitute in a marker for the string |
111 | - $clean .= "___" . count($literal_strings) . "___"; |
|
111 | + $clean .= "___".count($literal_strings)."___"; |
|
112 | 112 | |
113 | 113 | //push the string onto our array |
114 | - array_push($literal_strings,$literal); |
|
114 | + array_push($literal_strings, $literal); |
|
115 | 115 | |
116 | 116 | } |
117 | - else if($inComment && $d=="*/") |
|
117 | + else if ($inComment && $d == "*/") |
|
118 | 118 | { |
119 | 119 | $inComment = false; |
120 | 120 | $literal .= $d; |
121 | 121 | |
122 | 122 | //subsitute in a marker for the string |
123 | - $clean .= "___" . count($literal_strings) . "___"; |
|
123 | + $clean .= "___".count($literal_strings)."___"; |
|
124 | 124 | |
125 | 125 | //push the string onto our array |
126 | - array_push($literal_strings,$literal); |
|
126 | + array_push($literal_strings, $literal); |
|
127 | 127 | |
128 | 128 | $j++; |
129 | 129 | } |
130 | - else if($c == "\\" && !$escaped) |
|
130 | + else if ($c == "\\" && !$escaped) |
|
131 | 131 | $escaped = true; |
132 | 132 | else |
133 | 133 | $escaped = false; |
@@ -135,47 +135,47 @@ discard block |
||
135 | 135 | $literal .= $c; |
136 | 136 | } |
137 | 137 | } |
138 | - if($inComment) $literal .= "\n"; |
|
138 | + if ($inComment) $literal .= "\n"; |
|
139 | 139 | $clean .= "\n"; |
140 | 140 | } |
141 | 141 | //explode the clean string into lines again |
142 | - $lines = explode("\n",$clean); |
|
142 | + $lines = explode("\n", $clean); |
|
143 | 143 | |
144 | 144 | //now process each line at a time |
145 | - for($i=0;$i<count($lines);$i++) |
|
145 | + for ($i = 0; $i < count($lines); $i++) |
|
146 | 146 | { |
147 | 147 | $line = $lines[$i]; |
148 | 148 | |
149 | 149 | //remove comments |
150 | - $line = preg_replace("/\/\/(.*)/","",$line); |
|
150 | + $line = preg_replace("/\/\/(.*)/", "", $line); |
|
151 | 151 | |
152 | 152 | //strip leading and trailing whitespace |
153 | 153 | $line = trim($line); |
154 | 154 | |
155 | 155 | //remove all whitespace with a single space |
156 | - $line = preg_replace("/\s+/"," ",$line); |
|
156 | + $line = preg_replace("/\s+/", " ", $line); |
|
157 | 157 | |
158 | 158 | //remove any whitespace that occurs after/before an operator |
159 | - $line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line); |
|
159 | + $line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/", "\\1", $line); |
|
160 | 160 | |
161 | 161 | $lines[$i] = $line; |
162 | 162 | } |
163 | 163 | |
164 | 164 | //implode the lines |
165 | - $sJS = implode("\n",$lines); |
|
165 | + $sJS = implode("\n", $lines); |
|
166 | 166 | |
167 | 167 | //make sure there is a max of 1 \n after each line |
168 | - $sJS = preg_replace("/[\n]+/","\n",$sJS); |
|
168 | + $sJS = preg_replace("/[\n]+/", "\n", $sJS); |
|
169 | 169 | |
170 | 170 | //strip out line breaks that immediately follow a semi-colon |
171 | - $sJS = preg_replace("/;\n/",";",$sJS); |
|
171 | + $sJS = preg_replace("/;\n/", ";", $sJS); |
|
172 | 172 | |
173 | 173 | //curly brackets aren't on their own |
174 | - $sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS); |
|
174 | + $sJS = preg_replace("/[\n]*\{[\n]*/", "{", $sJS); |
|
175 | 175 | |
176 | 176 | //finally loop through and replace all the literal strings: |
177 | - for($i=0;$i<count($literal_strings);$i++) |
|
178 | - $sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS); |
|
177 | + for ($i = 0; $i < count($literal_strings); $i++) |
|
178 | + $sJS = str_replace("___".$i."___", $literal_strings[$i], $sJS); |
|
179 | 179 | |
180 | 180 | return $sJS; |
181 | 181 | } |
@@ -80,8 +80,7 @@ discard block |
||
80 | 80 | $escaped = false; |
81 | 81 | $quoteChar = $c; |
82 | 82 | $literal = $c; |
83 | - } |
|
84 | - else if($d=="/*" && !$inNormalComment) |
|
83 | + } else if($d=="/*" && !$inNormalComment) |
|
85 | 84 | { |
86 | 85 | $inQuote = false; |
87 | 86 | $inComment = true; |
@@ -89,18 +88,17 @@ discard block |
||
89 | 88 | $quoteChar = $d; |
90 | 89 | $literal = $d; |
91 | 90 | $j++; |
92 | - } |
|
93 | - else if($d=="//") //ignore string markers that are found inside comments |
|
91 | + } else if($d=="//") { |
|
92 | + //ignore string markers that are found inside comments |
|
94 | 93 | { |
95 | 94 | $inNormalComment = true; |
96 | - $clean .= $c; |
|
97 | 95 | } |
98 | - else |
|
96 | + $clean .= $c; |
|
97 | + } else |
|
99 | 98 | { |
100 | 99 | $clean .= $c; |
101 | 100 | } |
102 | - } |
|
103 | - else //allready in a string so find end quote |
|
101 | + } else //allready in a string so find end quote |
|
104 | 102 | { |
105 | 103 | if($c == $quoteChar && !$escaped && !$inComment) |
106 | 104 | { |
@@ -113,8 +111,7 @@ discard block |
||
113 | 111 | //push the string onto our array |
114 | 112 | array_push($literal_strings,$literal); |
115 | 113 | |
116 | - } |
|
117 | - else if($inComment && $d=="*/") |
|
114 | + } else if($inComment && $d=="*/") |
|
118 | 115 | { |
119 | 116 | $inComment = false; |
120 | 117 | $literal .= $d; |
@@ -126,16 +123,18 @@ discard block |
||
126 | 123 | array_push($literal_strings,$literal); |
127 | 124 | |
128 | 125 | $j++; |
126 | + } else if($c == "\\" && !$escaped) { |
|
127 | + $escaped = true; |
|
128 | + } else { |
|
129 | + $escaped = false; |
|
129 | 130 | } |
130 | - else if($c == "\\" && !$escaped) |
|
131 | - $escaped = true; |
|
132 | - else |
|
133 | - $escaped = false; |
|
134 | 131 | |
135 | 132 | $literal .= $c; |
136 | 133 | } |
137 | 134 | } |
138 | - if($inComment) $literal .= "\n"; |
|
135 | + if($inComment) { |
|
136 | + $literal .= "\n"; |
|
137 | + } |
|
139 | 138 | $clean .= "\n"; |
140 | 139 | } |
141 | 140 | //explode the clean string into lines again |
@@ -174,8 +173,9 @@ discard block |
||
174 | 173 | $sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS); |
175 | 174 | |
176 | 175 | //finally loop through and replace all the literal strings: |
177 | - for($i=0;$i<count($literal_strings);$i++) |
|
178 | - $sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS); |
|
176 | + for($i=0;$i<count($literal_strings);$i++) { |
|
177 | + $sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS); |
|
178 | + } |
|
179 | 179 | |
180 | 180 | return $sJS; |
181 | 181 | } |
@@ -121,6 +121,9 @@ |
||
121 | 121 | return $form->isSubmitted() == false || $form->validate(); |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @param string $format |
|
126 | + */ |
|
124 | 127 | function get_ceiling($format = null) |
125 | 128 | { |
126 | 129 | $result = Request::get('ceiling'); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | $action = $this->get_action(); |
170 | - $f = array($this, 'action_' . $action); |
|
170 | + $f = array($this, 'action_'.$action); |
|
171 | 171 | if (is_callable($f)) { |
172 | 172 | return call_user_func($f, $ids); |
173 | 173 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $text = get_lang('No'); |
293 | 293 | } |
294 | 294 | |
295 | - $result = Display::return_icon($image . '.png', $text); |
|
295 | + $result = Display::return_icon($image.'.png', $text); |
|
296 | 296 | return $result; |
297 | 297 | } |
298 | 298 |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * This function return the value of a php.ini setting if not "" or if exists, |
98 | 98 | * otherwise return false |
99 | 99 | * @param string $phpSetting The name of a PHP setting |
100 | - * @return mixed The value of the setting, or false if not found |
|
100 | + * @return string|false The value of the setting, or false if not found |
|
101 | 101 | */ |
102 | 102 | function checkPhpSettingExists($phpSetting) |
103 | 103 | { |
@@ -1268,6 +1268,10 @@ discard block |
||
1268 | 1268 | * @param string Extra notice (to show on the right side) |
1269 | 1269 | * @param boolean Whether to display in update mode |
1270 | 1270 | * @param string Additional attribute for the <tr> element |
1271 | + * @param string $installType |
|
1272 | + * @param string $parameterName |
|
1273 | + * @param string $formFieldName |
|
1274 | + * @param string $extra_notice |
|
1271 | 1275 | * @return void Direct output |
1272 | 1276 | */ |
1273 | 1277 | function displayDatabaseParameter( |
@@ -1481,6 +1485,11 @@ discard block |
||
1481 | 1485 | |
1482 | 1486 | <?php |
1483 | 1487 | } |
1488 | +/** |
|
1489 | + * @param string $content |
|
1490 | + * @param string $title |
|
1491 | + * @param string $id |
|
1492 | + */ |
|
1484 | 1493 | function panel($content = null, $title = null, $id = null, $style = null) { |
1485 | 1494 | $html = ''; |
1486 | 1495 | if (empty($style)) { |
@@ -1837,8 +1846,8 @@ discard block |
||
1837 | 1846 | } |
1838 | 1847 | |
1839 | 1848 | /** |
1840 | - * @param $current_value |
|
1841 | - * @param $wanted_value |
|
1849 | + * @param string $current_value |
|
1850 | + * @param string $wanted_value |
|
1842 | 1851 | * @return string |
1843 | 1852 | */ |
1844 | 1853 | function compare_setting_values($current_value, $wanted_value) |
@@ -1855,8 +1864,8 @@ discard block |
||
1855 | 1864 | } |
1856 | 1865 | |
1857 | 1866 | /** |
1858 | - * @param $course_dir |
|
1859 | - * @param $course_attempt_name |
|
1867 | + * @param string $course_dir |
|
1868 | + * @param string $course_attempt_name |
|
1860 | 1869 | * @param string $file |
1861 | 1870 | * @return bool |
1862 | 1871 | */ |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | if (!is_array($result)) { |
397 | 397 | $result = array(); |
398 | 398 | $exceptions = array('.', '..', 'CVS', '.svn'); |
399 | - $search = array('_latin', '_unicode', '_corporate', '_org' , '_KM', '_'); |
|
399 | + $search = array('_latin', '_unicode', '_corporate', '_org', '_KM', '_'); |
|
400 | 400 | $replace_with = array(' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' '); |
401 | 401 | $dirname = api_get_path(SYS_LANG_PATH); |
402 | 402 | $handle = opendir($dirname); |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | if ($handle = opendir($directory)) { |
431 | 431 | while (false !== ($file = readdir($handle))) { |
432 | 432 | if ($file != "." && $file != "..") { |
433 | - if (is_dir($directory. "/" . $file)) { |
|
434 | - $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file)); |
|
435 | - $file = $directory . "/" . $file; |
|
433 | + if (is_dir($directory."/".$file)) { |
|
434 | + $array_items = array_merge($array_items, my_directory_to_array($directory.'/'.$file)); |
|
435 | + $file = $directory."/".$file; |
|
436 | 436 | $array_items[] = preg_replace("/\/\//si", '/', $file); |
437 | 437 | } |
438 | 438 | } |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | <h2><?php get_lang('WelcomeToTheChamiloInstaller'); ?></h2> |
637 | 637 | <div class="RequirementHeading"> |
638 | 638 | <h2><?php echo display_step_sequence(); ?> |
639 | - <?php echo get_lang('InstallationLanguage');?> |
|
639 | + <?php echo get_lang('InstallationLanguage'); ?> |
|
640 | 640 | </h2> |
641 | 641 | <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage'); ?>:</p> |
642 | 642 | <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>"> |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | if (phpversion() < REQUIRED_PHP_VERSION) { |
710 | 710 | echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>'; |
711 | 711 | } else { |
712 | - echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>'; |
|
712 | + echo '<strong><font color="green">'.get_lang('PHPVersionOK').' '.phpversion().'</font></strong>'; |
|
713 | 713 | } |
714 | 714 | echo '</td> |
715 | 715 | </tr> |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | if ($file_course_test_was_created == true) { |
882 | 882 | break; |
883 | 883 | } |
884 | - $r = @touch($course_dir.'/test.php',$perm); |
|
884 | + $r = @touch($course_dir.'/test.php', $perm); |
|
885 | 885 | if ($r === true) { |
886 | 886 | $fil_perm_verified = $perm; |
887 | 887 | if (check_course_script_interpretation($course_dir, $course_attempt_name, 'test.php')) { |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | function get_contact_registration_form() |
1138 | 1138 | { |
1139 | 1139 | |
1140 | - $html =' |
|
1140 | + $html = ' |
|
1141 | 1141 | <form class="form-horizontal"> |
1142 | 1142 | <div class="panel panel-default"> |
1143 | 1143 | <div class="panel-body"> |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | <div class="col-sm-9"> |
1235 | 1235 | <div class="radio"> |
1236 | 1236 | <label> |
1237 | - <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes') . ' |
|
1237 | + <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes').' |
|
1238 | 1238 | </label> |
1239 | 1239 | </div> |
1240 | 1240 | <div class="radio"> |
@@ -1293,8 +1293,8 @@ discard block |
||
1293 | 1293 | echo '<input type="hidden" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'; |
1294 | 1294 | echo api_htmlentities($parameterValue); |
1295 | 1295 | } else { |
1296 | - echo '<div class="col-sm-5"><input type="' . $inputType . '" class="form-control" size="' . DATABASE_FORM_FIELD_DISPLAY_LENGTH . '" maxlength="' . $maxLength . '" name="' . $formFieldName . '" id="' . $formFieldName . '" value="' . api_htmlentities($parameterValue) . '" />' . "</div>"; |
|
1297 | - echo '<div class="col-sm-3">' . $extra_notice . '</div>'; |
|
1296 | + echo '<div class="col-sm-5"><input type="'.$inputType.'" class="form-control" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxLength.'" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'."</div>"; |
|
1297 | + echo '<div class="col-sm-3">'.$extra_notice.'</div>'; |
|
1298 | 1298 | } |
1299 | 1299 | |
1300 | 1300 | } |
@@ -1330,12 +1330,12 @@ discard block |
||
1330 | 1330 | $dbNameForm = $_configuration['main_database']; |
1331 | 1331 | $dbPortForm = isset($_configuration['db_port']) ? $_configuration['db_port'] : ''; |
1332 | 1332 | |
1333 | - echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>'; |
|
1333 | + echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>'; |
|
1334 | 1334 | echo '<div class="RequirementContent">'; |
1335 | 1335 | echo get_lang('DBSettingUpgradeIntro'); |
1336 | 1336 | echo '</div>'; |
1337 | 1337 | } else { |
1338 | - echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>'; |
|
1338 | + echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>'; |
|
1339 | 1339 | echo '<div class="RequirementContent">'; |
1340 | 1340 | echo get_lang('DBSettingIntro'); |
1341 | 1341 | echo '</div>'; |
@@ -1345,12 +1345,12 @@ discard block |
||
1345 | 1345 | <div class="panel-body"> |
1346 | 1346 | <div class="form-group"> |
1347 | 1347 | <label class="col-sm-4"><?php echo get_lang('DBHost'); ?> </label> |
1348 | - <?php if ($installType == 'update'){ ?> |
|
1348 | + <?php if ($installType == 'update') { ?> |
|
1349 | 1349 | <div class="col-sm-5"> |
1350 | 1350 | <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?> |
1351 | 1351 | </div> |
1352 | 1352 | <div class="col-sm-3"></div> |
1353 | - <?php }else{ ?> |
|
1353 | + <?php } else { ?> |
|
1354 | 1354 | <div class="col-sm-5"> |
1355 | 1355 | <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /> |
1356 | 1356 | </div> |
@@ -1359,12 +1359,12 @@ discard block |
||
1359 | 1359 | </div> |
1360 | 1360 | <div class="form-group"> |
1361 | 1361 | <label class="col-sm-4"><?php echo get_lang('DBPort'); ?> </label> |
1362 | - <?php if ($installType == 'update'){ ?> |
|
1362 | + <?php if ($installType == 'update') { ?> |
|
1363 | 1363 | <div class="col-sm-5"> |
1364 | 1364 | <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?> |
1365 | 1365 | </div> |
1366 | 1366 | <div class="col-sm-3"></div> |
1367 | - <?php }else{ ?> |
|
1367 | + <?php } else { ?> |
|
1368 | 1368 | <div class="col-sm-5"> |
1369 | 1369 | <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /> |
1370 | 1370 | </div> |
@@ -1390,7 +1390,7 @@ discard block |
||
1390 | 1390 | <?php |
1391 | 1391 | //Database Name fix replace weird chars |
1392 | 1392 | if ($installType != INSTALL_TYPE_UPDATE) { |
1393 | - $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm); |
|
1393 | + $dbNameForm = str_replace(array('-', '*', '$', ' ', '.'), '', $dbNameForm); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | displayDatabaseParameter( |
@@ -1489,7 +1489,7 @@ discard block |
||
1489 | 1489 | if (!empty($title)) { |
1490 | 1490 | $panelTitle = Display::div($title, array('class' => 'panel-heading')); |
1491 | 1491 | $panelBody = Display::div($content, array('class' => 'panel-body')); |
1492 | - $panelParent = Display::div($panelTitle . $panelBody, array('id' => $id, 'class' => 'panel panel-'.$style)); |
|
1492 | + $panelParent = Display::div($panelTitle.$panelBody, array('id' => $id, 'class' => 'panel panel-'.$style)); |
|
1493 | 1493 | } else { |
1494 | 1494 | $panelBody = Display::div($html, array('class' => 'panel-body')); |
1495 | 1495 | $panelParent = Display::div($panelBody, array('id' => $id, 'class' => 'panel panel-'.$style)); |
@@ -1514,9 +1514,9 @@ discard block |
||
1514 | 1514 | $displayWhenUpdate = 'true' |
1515 | 1515 | ) { |
1516 | 1516 | $html = '<div class="form-group">'; |
1517 | - $html .= '<label class="col-sm-6 control-label">' . $parameterName . '</label>'; |
|
1517 | + $html .= '<label class="col-sm-6 control-label">'.$parameterName.'</label>'; |
|
1518 | 1518 | if ($installType == INSTALL_TYPE_UPDATE && $displayWhenUpdate) { |
1519 | - $html .= '<input type="hidden" name="' . $formFieldName . '" value="'. api_htmlentities($parameterValue, ENT_QUOTES). '" />' . $parameterValue; |
|
1519 | + $html .= '<input type="hidden" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'.$parameterValue; |
|
1520 | 1520 | } else { |
1521 | 1521 | $html .= '<div class="col-sm-6"><input class="form-control" type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'."</div>"; |
1522 | 1522 | } |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | $languageForm = $_SESSION['install_language']; |
1564 | 1564 | } |
1565 | 1565 | echo '<div class="RequirementHeading">'; |
1566 | - echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>"; |
|
1566 | + echo "<h2>".display_step_sequence().get_lang("CfgSetting")."</h2>"; |
|
1567 | 1567 | echo '</div>'; |
1568 | 1568 | |
1569 | 1569 | echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>app/config/configuration.php</strong></p>'; |
@@ -1581,14 +1581,14 @@ discard block |
||
1581 | 1581 | |
1582 | 1582 | // Parameters 3 and 4: administrator's names |
1583 | 1583 | |
1584 | - $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); |
|
1585 | - $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName); |
|
1584 | + $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); |
|
1585 | + $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName); |
|
1586 | 1586 | |
1587 | 1587 | //Parameter 3: administrator's email |
1588 | - $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm); |
|
1588 | + $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm); |
|
1589 | 1589 | |
1590 | 1590 | //Parameter 6: administrator's telephone |
1591 | - $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm); |
|
1591 | + $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm); |
|
1592 | 1592 | |
1593 | 1593 | |
1594 | 1594 | echo panel($html, get_lang('Administrator'), 'administrator'); |
@@ -1607,12 +1607,12 @@ discard block |
||
1607 | 1607 | $html .= display_language_selection_box('languageForm', $languageForm); |
1608 | 1608 | $html .= '</div>'; |
1609 | 1609 | } |
1610 | - $html.= "</div>"; |
|
1610 | + $html .= "</div>"; |
|
1611 | 1611 | |
1612 | 1612 | |
1613 | 1613 | //Second parameter: Chamilo URL |
1614 | 1614 | $html .= '<div class="form-group">'; |
1615 | - $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL') .get_lang('ThisFieldIsRequired').'</label>'; |
|
1615 | + $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL').get_lang('ThisFieldIsRequired').'</label>'; |
|
1616 | 1616 | |
1617 | 1617 | |
1618 | 1618 | |
@@ -1636,34 +1636,34 @@ discard block |
||
1636 | 1636 | |
1637 | 1637 | |
1638 | 1638 | $html .= '<div class="form-group"> |
1639 | - <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass") . '</label> |
|
1639 | + <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass").'</label> |
|
1640 | 1640 | <div class="col-sm-6">'; |
1641 | 1641 | if ($installType == 'update') { |
1642 | - $html .= '<input type="hidden" name="encryptPassForm" value="'. $encryptPassForm .'" />'. $encryptPassForm; |
|
1642 | + $html .= '<input type="hidden" name="encryptPassForm" value="'.$encryptPassForm.'" />'.$encryptPassForm; |
|
1643 | 1643 | } else { |
1644 | 1644 | |
1645 | 1645 | $html .= '<div class="checkbox"> |
1646 | 1646 | <label> |
1647 | - <input type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ':'') .'/> bcrypt |
|
1647 | + <input type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ' : '').'/> bcrypt |
|
1648 | 1648 | </label>'; |
1649 | 1649 | |
1650 | 1650 | $html .= '<label> |
1651 | - <input type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ':'') .'/> sha1 |
|
1651 | + <input type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ' : '').'/> sha1 |
|
1652 | 1652 | </label>'; |
1653 | 1653 | |
1654 | 1654 | $html .= '<label> |
1655 | - <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ':'') .'/> md5 |
|
1655 | + <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ' : '').'/> md5 |
|
1656 | 1656 | </label>'; |
1657 | 1657 | |
1658 | 1658 | $html .= '<label> |
1659 | - <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ':'') .'/>'. get_lang('None').' |
|
1659 | + <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ' : '').'/>'.get_lang('None').' |
|
1660 | 1660 | </label>'; |
1661 | 1661 | $html .= '</div>'; |
1662 | 1662 | } |
1663 | 1663 | $html .= '</div></div>'; |
1664 | 1664 | |
1665 | 1665 | $html .= '<div class="form-group"> |
1666 | - <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg') . '</label> |
|
1666 | + <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg').'</label> |
|
1667 | 1667 | <div class="col-sm-6">'; |
1668 | 1668 | if ($installType == 'update') { |
1669 | 1669 | if ($allowSelfReg == 'true') { |
@@ -1673,17 +1673,17 @@ discard block |
||
1673 | 1673 | } else { |
1674 | 1674 | $label = get_lang('AfterApproval'); |
1675 | 1675 | } |
1676 | - $html .= '<input type="hidden" name="allowSelfReg" value="'. $allowSelfReg .'" />'. $label; |
|
1676 | + $html .= '<input type="hidden" name="allowSelfReg" value="'.$allowSelfReg.'" />'.$label; |
|
1677 | 1677 | } else { |
1678 | 1678 | $html .= '<div class="control-group">'; |
1679 | 1679 | $html .= '<label class="checkbox-inline"> |
1680 | - <input type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '') . ' /> '. get_lang('Yes') .' |
|
1680 | + <input type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '').' /> '.get_lang('Yes').' |
|
1681 | 1681 | </label>'; |
1682 | 1682 | $html .= '<label class="checkbox-inline"> |
1683 | - <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .' |
|
1683 | + <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ').' /> '.get_lang('No').' |
|
1684 | 1684 | </label>'; |
1685 | 1685 | $html .= '<label class="checkbox-inline"> |
1686 | - <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .' |
|
1686 | + <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ').' /> '.get_lang('AfterApproval').' |
|
1687 | 1687 | </label>'; |
1688 | 1688 | $html .= '</div>'; |
1689 | 1689 | } |
@@ -1691,7 +1691,7 @@ discard block |
||
1691 | 1691 | $html .= '</div>'; |
1692 | 1692 | |
1693 | 1693 | $html .= '<div class="form-group">'; |
1694 | - $html .= '<label class="col-sm-6 control-label">'. get_lang('AllowSelfRegProf') .'</label> |
|
1694 | + $html .= '<label class="col-sm-6 control-label">'.get_lang('AllowSelfRegProf').'</label> |
|
1695 | 1695 | <div class="col-sm-6">'; |
1696 | 1696 | if ($installType == 'update') { |
1697 | 1697 | if ($allowSelfRegProf == 'true') { |
@@ -1699,16 +1699,16 @@ discard block |
||
1699 | 1699 | } else { |
1700 | 1700 | $label = get_lang('No'); |
1701 | 1701 | } |
1702 | - $html .= '<input type="hidden" name="allowSelfRegProf" value="'. $allowSelfRegProf.'" />'. $label; |
|
1702 | + $html .= '<input type="hidden" name="allowSelfRegProf" value="'.$allowSelfRegProf.'" />'.$label; |
|
1703 | 1703 | } else { |
1704 | 1704 | $html .= '<div class="control-group"> |
1705 | 1705 | <label class="checkbox-inline"> |
1706 | - <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '') .'/> |
|
1707 | - ' . get_lang('Yes') .' |
|
1706 | + <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '').'/> |
|
1707 | + ' . get_lang('Yes').' |
|
1708 | 1708 | </label>'; |
1709 | 1709 | $html .= '<label class="checkbox-inline"> |
1710 | - <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ') .' /> |
|
1711 | - '. get_lang('No') .' |
|
1710 | + <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ').' /> |
|
1711 | + '. get_lang('No').' |
|
1712 | 1712 | </label>'; |
1713 | 1713 | $html .= '</div>'; |
1714 | 1714 | } |
@@ -1773,7 +1773,7 @@ discard block |
||
1773 | 1773 | "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", |
1774 | 1774 | "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", |
1775 | 1775 | "Oman", |
1776 | - "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland","Portugal", |
|
1776 | + "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", |
|
1777 | 1777 | "Qatar", |
1778 | 1778 | "Romania", "Russia", "Rwanda", |
1779 | 1779 | "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", |
@@ -1820,11 +1820,11 @@ discard block |
||
1820 | 1820 | $permissions_for_new_directories = isset($_SESSION['permissions_for_new_directories']) ? $_SESSION['permissions_for_new_directories'] : 0770; |
1821 | 1821 | $permissions_for_new_files = isset($_SESSION['permissions_for_new_files']) ? $_SESSION['permissions_for_new_files'] : 0660; |
1822 | 1822 | // use decoct() to store as string |
1823 | - $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_directories) . "' |
|
1823 | + $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_directories)."' |
|
1824 | 1824 | WHERE variable = 'permissions_for_new_directories'"; |
1825 | 1825 | Database::query($sql); |
1826 | 1826 | |
1827 | - $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_files) . "' WHERE variable = 'permissions_for_new_files'"; |
|
1827 | + $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_files)."' WHERE variable = 'permissions_for_new_files'"; |
|
1828 | 1828 | Database::query($sql); |
1829 | 1829 | |
1830 | 1830 | if (isset($_SESSION['permissions_for_new_directories'])) { |
@@ -1844,8 +1844,8 @@ discard block |
||
1844 | 1844 | function compare_setting_values($current_value, $wanted_value) |
1845 | 1845 | { |
1846 | 1846 | $current_value_string = $current_value; |
1847 | - $current_value = (float)$current_value; |
|
1848 | - $wanted_value = (float)$wanted_value; |
|
1847 | + $current_value = (float) $current_value; |
|
1848 | + $wanted_value = (float) $wanted_value; |
|
1849 | 1849 | |
1850 | 1850 | if ($current_value >= $wanted_value) { |
1851 | 1851 | return Display::label($current_value_string, 'success'); |
@@ -1896,7 +1896,7 @@ discard block |
||
1896 | 1896 | |
1897 | 1897 | fwrite($fp, $out); |
1898 | 1898 | while (!feof($fp)) { |
1899 | - $result = str_replace("\r\n", '',fgets($fp, 128)); |
|
1899 | + $result = str_replace("\r\n", '', fgets($fp, 128)); |
|
1900 | 1900 | if (!empty($result) && $result == '123') { |
1901 | 1901 | $output = true; |
1902 | 1902 | } |
@@ -1919,7 +1919,7 @@ discard block |
||
1919 | 1919 | curl_setopt($ch, CURLOPT_URL, $url); |
1920 | 1920 | //curl_setopt($ch, CURLOPT_TIMEOUT, 30); |
1921 | 1921 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
1922 | - $result = curl_exec ($ch); |
|
1922 | + $result = curl_exec($ch); |
|
1923 | 1923 | if (!empty($result) && $result == '123') { |
1924 | 1924 | $output = true; |
1925 | 1925 | } |
@@ -2679,12 +2679,12 @@ discard block |
||
2679 | 2679 | $adminPhoneForm, |
2680 | 2680 | '', //$picture_uri = '', |
2681 | 2681 | PLATFORM_AUTH_SOURCE, |
2682 | - '',//$expirationDate, |
|
2682 | + '', //$expirationDate, |
|
2683 | 2683 | 1, |
2684 | 2684 | 0, |
2685 | 2685 | null, |
2686 | 2686 | '', |
2687 | - false, //$send_mail = false, |
|
2687 | + false, //$send_mail = false, |
|
2688 | 2688 | true //$isAdmin = false |
2689 | 2689 | ); |
2690 | 2690 | |
@@ -2706,7 +2706,7 @@ discard block |
||
2706 | 2706 | 0, |
2707 | 2707 | null, |
2708 | 2708 | '', |
2709 | - false, //$send_mail = false, |
|
2709 | + false, //$send_mail = false, |
|
2710 | 2710 | false //$isAdmin = false |
2711 | 2711 | ); |
2712 | 2712 | |
@@ -2772,7 +2772,7 @@ discard block |
||
2772 | 2772 | SET selected_value = '".$param->selected_value."' |
2773 | 2773 | WHERE variable = '".$param->variable."'"; |
2774 | 2774 | if (!empty($param->subkey)) { |
2775 | - $sql .= " AND subkey='" . $param->subkey . "'"; |
|
2775 | + $sql .= " AND subkey='".$param->subkey."'"; |
|
2776 | 2776 | } |
2777 | 2777 | Database::query($sql); |
2778 | 2778 | } |
@@ -1682,7 +1682,7 @@ discard block |
||
1682 | 1682 | $html .= '<label class="checkbox-inline"> |
1683 | 1683 | <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .' |
1684 | 1684 | </label>'; |
1685 | - $html .= '<label class="checkbox-inline"> |
|
1685 | + $html .= '<label class="checkbox-inline"> |
|
1686 | 1686 | <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .' |
1687 | 1687 | </label>'; |
1688 | 1688 | $html .= '</div>'; |
@@ -1716,7 +1716,7 @@ discard block |
||
1716 | 1716 | </div>'; |
1717 | 1717 | |
1718 | 1718 | echo panel($html, get_lang('Platform'), 'platform'); |
1719 | - ?> |
|
1719 | + ?> |
|
1720 | 1720 | <div class='form-group'> |
1721 | 1721 | <div class="col-sm-6"> |
1722 | 1722 | <button type="submit" class="btn btn-default pull-right" name="step3" value="< <?php echo get_lang('Previous'); ?>" ><em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?></button> |
@@ -973,8 +973,7 @@ discard block |
||
973 | 973 | <?php echo get_lang('Error'); ?>!<br /> |
974 | 974 | Chamilo <?php echo implode('|', $update_from_version_8).' '.get_lang('HasNotBeenFoundInThatDir'); ?>. |
975 | 975 | </div> |
976 | - <?php } |
|
977 | - else { |
|
976 | + <?php } else { |
|
978 | 977 | echo '<br />'; |
979 | 978 | } |
980 | 979 | ?> |
@@ -1060,14 +1059,19 @@ discard block |
||
1060 | 1059 | <button type="submit" name="step1" class="btn btn-default" onclick="javascript: window.location='index.php'; return false;" value="<?php echo get_lang('Previous'); ?>" > |
1061 | 1060 | <em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?> |
1062 | 1061 | </button> |
1063 | - <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) echo 'disabled="disabled"'; ?> > |
|
1062 | + <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) { |
|
1063 | + echo 'disabled="disabled"'; |
|
1064 | +} |
|
1065 | +?> > |
|
1064 | 1066 | <em class="fa fa-forward"> </em> <?php echo get_lang('NewInstallation'); ?> |
1065 | 1067 | </button> |
1066 | 1068 | <input type="hidden" name="is_executable" id="is_executable" value="-" /> |
1067 | 1069 | <?php |
1068 | 1070 | // Real code |
1069 | 1071 | echo '<button type="submit" class="btn btn-default" name="step2_update_8" value="Upgrade from Chamilo 1.9.x"'; |
1070 | - if ($error) echo ' disabled="disabled"'; |
|
1072 | + if ($error) { |
|
1073 | + echo ' disabled="disabled"'; |
|
1074 | + } |
|
1071 | 1075 | echo ' ><em class="fa fa-forward"> </em> '.get_lang('UpgradeFromLMS19x').'</button>'; |
1072 | 1076 | |
1073 | 1077 | echo '</p>'; |
@@ -1350,7 +1354,7 @@ discard block |
||
1350 | 1354 | <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?> |
1351 | 1355 | </div> |
1352 | 1356 | <div class="col-sm-3"></div> |
1353 | - <?php }else{ ?> |
|
1357 | + <?php } else{ ?> |
|
1354 | 1358 | <div class="col-sm-5"> |
1355 | 1359 | <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /> |
1356 | 1360 | </div> |
@@ -1364,7 +1368,7 @@ discard block |
||
1364 | 1368 | <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?> |
1365 | 1369 | </div> |
1366 | 1370 | <div class="col-sm-3"></div> |
1367 | - <?php }else{ ?> |
|
1371 | + <?php } else{ ?> |
|
1368 | 1372 | <div class="col-sm-5"> |
1369 | 1373 | <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /> |
1370 | 1374 | </div> |
@@ -1446,9 +1450,12 @@ discard block |
||
1446 | 1450 | Database port: <strong><?php echo $manager->getConnection()->getPort(); ?></strong><br/> |
1447 | 1451 | Database driver: <strong><?php echo $manager->getConnection()->getDriver()->getName(); ?></strong><br/> |
1448 | 1452 | </div> |
1449 | - <?php else: ?> |
|
1453 | + <?php else { |
|
1454 | + : ?> |
|
1450 | 1455 | <div id="db_status" class="alert alert-danger"> |
1451 | - <p><?php echo get_lang('FailedConectionDatabase'); ?></strong></p> |
|
1456 | + <p><?php echo get_lang('FailedConectionDatabase'); |
|
1457 | +} |
|
1458 | +?></strong></p> |
|
1452 | 1459 | <code><?php echo $database_exists_text ?></code> |
1453 | 1460 | </div> |
1454 | 1461 | <?php endif; ?> |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | /** |
217 | 217 | * Import the aicc object (as a result from the parse_config_files function) into the database structure |
218 | 218 | * @param string $course_code |
219 | - * @return bool Returns -1 on error |
|
219 | + * @return false|null Returns -1 on error |
|
220 | 220 | */ |
221 | 221 | public function import_aicc($course_code) |
222 | 222 | { |
@@ -780,7 +780,8 @@ discard block |
||
780 | 780 | * Static function to parse AICC ini files. |
781 | 781 | * Based on work by sinedeo at gmail dot com published on php.net (parse_ini_file()). |
782 | 782 | * @param string File path |
783 | - * @return array Structured array |
|
783 | + * @param string $f |
|
784 | + * @return string Structured array |
|
784 | 785 | */ |
785 | 786 | function parse_ini_file_quotes_safe($f) { |
786 | 787 | $null = ''; |
@@ -831,7 +832,7 @@ discard block |
||
831 | 832 | * Based on work by sinedeo at gmail dot com published on php.net (parse_ini_file()). |
832 | 833 | * @param string INI File string |
833 | 834 | * @param array List of names of sections that should be considered as containing only hard string data (no variables), provided in lower case |
834 | - * @return array Structured array |
|
835 | + * @return string Structured array |
|
835 | 836 | */ |
836 | 837 | function parse_ini_string_quotes_safe($s, $pure_strings = array()) { |
837 | 838 | $null = ''; |
@@ -894,6 +895,7 @@ discard block |
||
894 | 895 | * @param string CSV delimiter |
895 | 896 | * @param string CSV enclosure |
896 | 897 | * @param boolean Might one field name happen more than once on the same line? (then split by comma in the values) |
898 | + * @param string $f |
|
897 | 899 | * @return array Simple structured array |
898 | 900 | */ |
899 | 901 | function parse_csv_file($f, $delim = ',', $enclosure = '"', $multiples = false) { |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - /** |
|
324 | - * Intermediate to import_package only to allow import from local zip files |
|
325 | - * @param string Path to the zip file, from the dokeos sys root |
|
326 | - * @param string Current path (optional) |
|
327 | - * @return string Absolute path to the AICC description files or empty string on error |
|
328 | - */ |
|
323 | + /** |
|
324 | + * Intermediate to import_package only to allow import from local zip files |
|
325 | + * @param string Path to the zip file, from the dokeos sys root |
|
326 | + * @param string Current path (optional) |
|
327 | + * @return string Absolute path to the AICC description files or empty string on error |
|
328 | + */ |
|
329 | 329 | function import_local_package($file_path, $current_dir = '') |
330 | 330 | { |
331 | 331 | // TODO: Prepare info as given by the $_FILES[''] vector. |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/ |
356 | 356 | if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Current_dir = '.$current_dir, 0); } |
357 | 357 | |
358 | - //$uploaded_filename = $_FILES['userFile']['name']; |
|
358 | + //$uploaded_filename = $_FILES['userFile']['name']; |
|
359 | 359 | // Get the name of the zip file without the extension. |
360 | 360 | if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Received zip file name: '.$zip_file_path, 0); } |
361 | 361 | $file_info = pathinfo($zip_file_name); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | class aicc extends learnpath |
13 | 13 | { |
14 | 14 | public $config = array(); |
15 | - public $config_basename = ''; // The configuration files might be multiple and might have |
|
15 | + public $config_basename = ''; // The configuration files might be multiple and might have |
|
16 | 16 | // funny names. We need to keep the name of that file while we |
17 | 17 | // install the content. |
18 | 18 | public $config_files = array(); |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | public $cstlist = array(); |
33 | 33 | public $orelist = array(); |
34 | 34 | |
35 | - public $subdir = ''; // Path between the scorm/ directory and the config files e.g. maritime_nav/maritime_nav. This is the path that will be used in the lp_path when importing a package. |
|
36 | - public $zipname = ''; // Keeps the zipfile safe for the object's life so that we can use it if there is no title available. |
|
37 | - public $lastzipnameindex = 0; // Keeps an index of the number of uses of the zipname so far. |
|
35 | + public $subdir = ''; // Path between the scorm/ directory and the config files e.g. maritime_nav/maritime_nav. This is the path that will be used in the lp_path when importing a package. |
|
36 | + public $zipname = ''; // Keeps the zipfile safe for the object's life so that we can use it if there is no title available. |
|
37 | + public $lastzipnameindex = 0; // Keeps an index of the number of uses of the zipname so far. |
|
38 | 38 | public $config_encoding = 'ISO-8859-1'; |
39 | 39 | public $debug = 0; |
40 | 40 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | //echo '<pre>des:'.print_r($des_params, true).'</pre>'; |
133 | 133 | if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$des_file.' has been parsed', 0); } |
134 | 134 | // Distribute des params into the aicc object. |
135 | - foreach ($des_params as $des){ |
|
135 | + foreach ($des_params as $des) { |
|
136 | 136 | // One AU in AICC is equivalent to one SCO in SCORM (scormItem class). |
137 | 137 | $oDes = new aiccResource('config', $des); |
138 | 138 | $this->deslist[$oDes->identifier] = $oDes; |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | |
243 | 243 | $this->config_encoding = "ISO-8859-1"; // TODO: We may apply detection for this value, see the function api_detect_encoding(). |
244 | 244 | |
245 | - $sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib, content_maker,display_order)" . |
|
246 | - "VALUES " . |
|
247 | - "($course_id, 3, '".$this->course_title."', '".$this->course_id."','".$this->course_description."'," . |
|
248 | - "'".$this->subdir."', 0, 'embedded', '".$this->config_encoding."'," . |
|
245 | + $sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib, content_maker,display_order)". |
|
246 | + "VALUES ". |
|
247 | + "($course_id, 3, '".$this->course_title."', '".$this->course_id."','".$this->course_description."',". |
|
248 | + "'".$this->subdir."', 0, 'embedded', '".$this->config_encoding."',". |
|
249 | 249 | "'aicc_api.php','".$this->course_creator."',$dsp)"; |
250 | - if ($this->debug > 2) { error_log('New LP - In import_aicc(), inserting path: '. $sql, 0); } |
|
250 | + if ($this->debug > 2) { error_log('New LP - In import_aicc(), inserting path: '.$sql, 0); } |
|
251 | 251 | Database::query($sql); |
252 | 252 | $lp_id = Database::insert_id(); |
253 | 253 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | $previous = 0; |
278 | 278 | foreach ($this->aulist as $identifier => $dummy) { |
279 | - $oAu =& $this->aulist[$identifier]; |
|
279 | + $oAu = & $this->aulist[$identifier]; |
|
280 | 280 | //echo "Item ".$oAu->identifier; |
281 | 281 | $field_add = ''; |
282 | 282 | $value_add = ''; |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | $parent = 0; // TODO: Deal with the parent. |
295 | 295 | $previous = 0; |
296 | 296 | $prereq = $oAu->prereq_string; |
297 | - $sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,parameters) " . |
|
298 | - "VALUES " . |
|
299 | - "($course_id, $lp_id, 'au','".$oAu->identifier."','".$title."'," . |
|
300 | - "'$path',0,100, $value_add" . |
|
301 | - "$parent, $previous, 0, " . |
|
302 | - "'$prereq', 0,'".(!empty($oAu->parameters)?Database::escape_string($oAu->parameters):'')."'" . |
|
297 | + $sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,parameters) ". |
|
298 | + "VALUES ". |
|
299 | + "($course_id, $lp_id, 'au','".$oAu->identifier."','".$title."',". |
|
300 | + "'$path',0,100, $value_add". |
|
301 | + "$parent, $previous, 0, ". |
|
302 | + "'$prereq', 0,'".(!empty($oAu->parameters) ? Database::escape_string($oAu->parameters) : '')."'". |
|
303 | 303 | ")"; |
304 | 304 | Database::query($sql_item); |
305 | 305 | if ($this->debug > 1) { error_log('New LP - In aicc::import_aicc() - inserting item : '.$sql_item.' : ', 0); } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | $zip_file_name = $zip_file_info['name']; |
351 | 351 | |
352 | 352 | if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name, 0); } |
353 | - $course_rel_dir = api_get_course_path().'/scorm'; // Scorm dir web path starting from /courses |
|
353 | + $course_rel_dir = api_get_course_path().'/scorm'; // Scorm dir web path starting from /courses |
|
354 | 354 | $course_sys_dir = api_get_path(SYS_COURSE_PATH).$course_rel_dir; // The absolute system path of this course. |
355 | 355 | $current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/ |
356 | 356 | if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Current_dir = '.$current_dir, 0); } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Base file name is : '.$file_base_name, 0); } |
368 | 368 | $new_dir = api_replace_dangerous_char(trim($file_base_name)); |
369 | 369 | $this->subdir = $new_dir; |
370 | - if($this->debug > 0) { error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir, 0); } |
|
370 | + if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir, 0); } |
|
371 | 371 | |
372 | 372 | /* |
373 | 373 | if (check_name_exist($course_sys_dir.$current_dir.'/'.$new_dir)) { |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | $subdir_isset = true; |
414 | 414 | } else { |
415 | 415 | if (!$subdir_isset) { |
416 | - if (preg_match('?^.*/aicc$?i',dirname($thisContent['filename']))) { |
|
416 | + if (preg_match('?^.*/aicc$?i', dirname($thisContent['filename']))) { |
|
417 | 417 | //echo "Cutting subdir<br/>"; |
418 | 418 | $this->subdir .= '/'.substr(dirname($thisContent['filename']), 0, -5); |
419 | 419 | } else { |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | // TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible! |
517 | 517 | //$safe_file = api_replace_dangerous_char($file, 'strict'); |
518 | 518 | $find_str = array('\\', '.php', '.phtml'); |
519 | - $repl_str = array('/', '.txt', '.txt'); |
|
519 | + $repl_str = array('/', '.txt', '.txt'); |
|
520 | 520 | $safe_file = str_replace($find_str, $repl_str, $file); |
521 | 521 | |
522 | 522 | if ($safe_file != $file) { |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | if ($this->debug > 0) { error_log('In aicc::get_res_path('.$id.') method', 0); } |
718 | 718 | $path = ''; |
719 | 719 | if (isset($this->resources[$id])) { |
720 | - $oRes =& $this->resources[$id]; |
|
720 | + $oRes = & $this->resources[$id]; |
|
721 | 721 | $path = @$oRes->get_path(); |
722 | 722 | } |
723 | 723 | return $path; |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | if ($this->debug > 0) { error_log('In aicc::get_res_type('.$id.') method', 0); } |
734 | 734 | $type = ''; |
735 | 735 | if (isset($this->resources[$id])) { |
736 | - $oRes =& $this->resources[$id]; |
|
736 | + $oRes = & $this->resources[$id]; |
|
737 | 737 | $temptype = $oRes->get_scorm_type(); |
738 | 738 | if (!empty($temptype)) { |
739 | 739 | $type = $temptype; |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | * Gets the default organisation's title |
747 | 747 | * @return string The organization's title |
748 | 748 | */ |
749 | - function get_title(){ |
|
749 | + function get_title() { |
|
750 | 750 | if ($this->debug > 0) { error_log('In aicc::get_title() method', 0); } |
751 | 751 | $title = ''; |
752 | 752 | if (isset($this->config['organizations']['default'])) { |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | $chr = $data{$i}; |
908 | 908 | switch ($chr) { |
909 | 909 | case $enclosure: |
910 | - if ($enclosed && $data{$i+1} == $enclosure) { |
|
910 | + if ($enclosed && $data{$i + 1} == $enclosure) { |
|
911 | 911 | $fldval .= $chr; |
912 | 912 | ++$i; // Skip the next character. |
913 | 913 | } else |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | $fldval .= $chr; |
922 | 922 | break; |
923 | 923 | case "\r": |
924 | - if (!$enclosed&&$data{$i+1} == "\n") |
|
924 | + if (!$enclosed && $data{$i + 1} == "\n") |
|
925 | 925 | continue; |
926 | 926 | case "\n": |
927 | 927 | if (!$enclosed) { |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | $fldval .= $chr; |
933 | 933 | break; |
934 | 934 | case "\\r": |
935 | - if (!$enclosed&&$data{$i+1} == "\\n") |
|
935 | + if (!$enclosed && $data{$i + 1} == "\\n") |
|
936 | 936 | continue; |
937 | 937 | case "\\n": |
938 | 938 | if (!$enclosed) { |
@@ -459,11 +459,12 @@ discard block |
||
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
462 | - if ($package_type == '' || !$mandatory) |
|
463 | - // && defined('CHECK_FOR_AICC') && CHECK_FOR_AICC) |
|
462 | + if ($package_type == '' || !$mandatory) { |
|
463 | + // && defined('CHECK_FOR_AICC') && CHECK_FOR_AICC) |
|
464 | 464 | { |
465 | 465 | return api_failure::set_failure('not_aicc_content'); |
466 | 466 | } |
467 | + } |
|
467 | 468 | |
468 | 469 | if (!enough_size($realFileSize, $course_sys_dir, $maxFilledSpace)) { |
469 | 470 | return api_failure::set_failure('not_enough_space'); |
@@ -511,7 +512,9 @@ discard block |
||
511 | 512 | if ($file != '.' && $file != '..') { |
512 | 513 | $filetype = 'file'; |
513 | 514 | |
514 | - if (is_dir($course_sys_dir.$new_dir.$file)) $filetype = 'folder'; |
|
515 | + if (is_dir($course_sys_dir.$new_dir.$file)) { |
|
516 | + $filetype = 'folder'; |
|
517 | + } |
|
515 | 518 | |
516 | 519 | // TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible! |
517 | 520 | //$safe_file = api_replace_dangerous_char($file, 'strict'); |
@@ -910,37 +913,43 @@ discard block |
||
910 | 913 | if ($enclosed && $data{$i+1} == $enclosure) { |
911 | 914 | $fldval .= $chr; |
912 | 915 | ++$i; // Skip the next character. |
913 | - } else |
|
914 | - $enclosed = !$enclosed; |
|
916 | + } else { |
|
917 | + $enclosed = !$enclosed; |
|
918 | + } |
|
915 | 919 | break; |
916 | 920 | case $delim: |
917 | 921 | if (!$enclosed) { |
918 | 922 | $ret_array[$linecount][$fldcount++] = $fldval; |
919 | 923 | $fldval = ''; |
920 | - } else |
|
921 | - $fldval .= $chr; |
|
924 | + } else { |
|
925 | + $fldval .= $chr; |
|
926 | + } |
|
922 | 927 | break; |
923 | 928 | case "\r": |
924 | - if (!$enclosed&&$data{$i+1} == "\n") |
|
925 | - continue; |
|
929 | + if (!$enclosed&&$data{$i+1} == "\n") { |
|
930 | + continue; |
|
931 | + } |
|
926 | 932 | case "\n": |
927 | 933 | if (!$enclosed) { |
928 | 934 | $ret_array[$linecount++][$fldcount] = $fldval; |
929 | 935 | $fldcount = 0; |
930 | 936 | $fldval = ''; |
931 | - } else |
|
932 | - $fldval .= $chr; |
|
937 | + } else { |
|
938 | + $fldval .= $chr; |
|
939 | + } |
|
933 | 940 | break; |
934 | 941 | case "\\r": |
935 | - if (!$enclosed&&$data{$i+1} == "\\n") |
|
936 | - continue; |
|
942 | + if (!$enclosed&&$data{$i+1} == "\\n") { |
|
943 | + continue; |
|
944 | + } |
|
937 | 945 | case "\\n": |
938 | 946 | if (!$enclosed) { |
939 | 947 | $ret_array[$linecount++][$fldcount] = $fldval; |
940 | 948 | $fldcount = 0; |
941 | 949 | $fldval = ''; |
942 | - } else |
|
943 | - $fldval .= $chr; |
|
950 | + } else { |
|
951 | + $fldval .= $chr; |
|
952 | + } |
|
944 | 953 | break; |
945 | 954 | default: |
946 | 955 | $fldval .= $chr; |
@@ -60,6 +60,7 @@ |
||
60 | 60 | /** |
61 | 61 | * This function deletes an entire directory |
62 | 62 | * @param string The directory path |
63 | + * @param string $dir |
|
63 | 64 | * @return boolean True on success, false on failure |
64 | 65 | */ |
65 | 66 | function deldir($dir) { |