@@ -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 |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | "; |
82 | 82 | $result = Database::query($sql); |
83 | 83 | if (Database::num_rows($result)) { |
84 | - $row = Database::fetch_array($result); |
|
84 | + $row = Database::fetch_array($result); |
|
85 | 85 | |
86 | 86 | return $row['count']; |
87 | 87 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | "; |
102 | 102 | $result = Database::query($sql); |
103 | 103 | if (Database::num_rows($result)) { |
104 | - $row = Database::fetch_array($result); |
|
104 | + $row = Database::fetch_array($result); |
|
105 | 105 | return $row['count']; |
106 | 106 | } |
107 | 107 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | "; |
127 | 127 | $result = Database::query($sql); |
128 | 128 | if (Database::num_rows($result)) { |
129 | - $row = Database::fetch_array($result); |
|
129 | + $row = Database::fetch_array($result); |
|
130 | 130 | return $row['count']; |
131 | 131 | } |
132 | 132 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | "; |
148 | 148 | $result = Database::query($sql); |
149 | 149 | if (Database::num_rows($result)) { |
150 | - $row = Database::fetch_array($result); |
|
150 | + $row = Database::fetch_array($result); |
|
151 | 151 | return $row['count']; |
152 | 152 | } |
153 | 153 | |
@@ -528,13 +528,13 @@ discard block |
||
528 | 528 | INNER JOIN {$this->table} g |
529 | 529 | ON (u.usergroup_id = g.id) |
530 | 530 | "; |
531 | - $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); |
|
531 | + $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); |
|
532 | 532 | } else { |
533 | 533 | $from = $this->usergroup_rel_user_table." u |
534 | 534 | INNER JOIN {$this->table} g |
535 | 535 | ON (u.usergroup_id = g.id) |
536 | 536 | "; |
537 | - $where = array('where' => array('user_id = ?' => $userId)); |
|
537 | + $where = array('where' => array('user_id = ?' => $userId)); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | if ($filterByType !== null) { |
@@ -567,10 +567,10 @@ discard block |
||
567 | 567 | $urlId = api_get_current_access_url_id(); |
568 | 568 | $from = $this->usergroup_rel_user_table." u |
569 | 569 | INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id AND u.usergroup_id)"; |
570 | - $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); |
|
570 | + $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); |
|
571 | 571 | } else { |
572 | 572 | $from = $this->usergroup_rel_user_table." u "; |
573 | - $where = array('where' => array('user_id = ?' => $userId)); |
|
573 | + $where = array('where' => array('user_id = ?' => $userId)); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | $results = Database::select( |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | } |
857 | 857 | $result = $new_result; |
858 | 858 | } |
859 | - $columns = array('name', 'users', 'courses','sessions', 'group_type'); |
|
859 | + $columns = array('name', 'users', 'courses', 'sessions', 'group_type'); |
|
860 | 860 | |
861 | 861 | if (!in_array($sidx, $columns)) { |
862 | 862 | $sidx = 'name'; |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | } |
1261 | 1261 | } |
1262 | 1262 | } |
1263 | - $response->addAssign('ajax_list_courses','innerHTML', api_utf8_encode($return)); |
|
1263 | + $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return)); |
|
1264 | 1264 | |
1265 | 1265 | return $response; |
1266 | 1266 | } |
@@ -1367,7 +1367,7 @@ discard block |
||
1367 | 1367 | * @param string style css |
1368 | 1368 | * @return array with the file and the style of an image i.e $array['file'] $array['style'] |
1369 | 1369 | */ |
1370 | - public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '') |
|
1370 | + public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '') |
|
1371 | 1371 | { |
1372 | 1372 | $picture = array(); |
1373 | 1373 | $picture['style'] = $style; |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | */ |
1481 | 1481 | public function getAllowedPictureExtensions() |
1482 | 1482 | { |
1483 | - return $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); |
|
1483 | + return $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | /** |
@@ -1514,7 +1514,7 @@ discard block |
||
1514 | 1514 | if (empty($user_id)) { |
1515 | 1515 | $user_id = api_get_user_id(); |
1516 | 1516 | } |
1517 | - $user_role = $this->get_user_group_role($user_id, $group_id); |
|
1517 | + $user_role = $this->get_user_group_role($user_id, $group_id); |
|
1518 | 1518 | if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN))) { |
1519 | 1519 | return true; |
1520 | 1520 | } else { |
@@ -1532,7 +1532,7 @@ discard block |
||
1532 | 1532 | if (empty($user_id)) { |
1533 | 1533 | $user_id = api_get_user_id(); |
1534 | 1534 | } |
1535 | - $user_role = $this->get_user_group_role($user_id, $group_id); |
|
1535 | + $user_role = $this->get_user_group_role($user_id, $group_id); |
|
1536 | 1536 | if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) { |
1537 | 1537 | return true; |
1538 | 1538 | } else { |
@@ -1559,7 +1559,7 @@ discard block |
||
1559 | 1559 | GROUP_USER_PERMISSION_READER, |
1560 | 1560 | GROUP_USER_PERMISSION_HRM, |
1561 | 1561 | ); |
1562 | - $user_role = self::get_user_group_role($user_id, $group_id); |
|
1562 | + $user_role = self::get_user_group_role($user_id, $group_id); |
|
1563 | 1563 | if (in_array($user_role, $roles)) { |
1564 | 1564 | return true; |
1565 | 1565 | } else { |
@@ -1576,7 +1576,7 @@ discard block |
||
1576 | 1576 | * */ |
1577 | 1577 | public function get_user_group_role($user_id, $group_id) |
1578 | 1578 | { |
1579 | - $table_group_rel_user= $this->usergroup_rel_user_table; |
|
1579 | + $table_group_rel_user = $this->usergroup_rel_user_table; |
|
1580 | 1580 | $return_value = 0; |
1581 | 1581 | if (!empty($user_id) && !empty($group_id)) { |
1582 | 1582 | $sql = "SELECT relation_type FROM $table_group_rel_user |
@@ -1584,8 +1584,8 @@ discard block |
||
1584 | 1584 | usergroup_id = ".intval($group_id)." AND |
1585 | 1585 | user_id = ".intval($user_id)." "; |
1586 | 1586 | $result = Database::query($sql); |
1587 | - if (Database::num_rows($result)>0) { |
|
1588 | - $row = Database::fetch_array($result,'ASSOC'); |
|
1587 | + if (Database::num_rows($result) > 0) { |
|
1588 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
1589 | 1589 | $return_value = $row['relation_type']; |
1590 | 1590 | } |
1591 | 1591 | } |
@@ -1640,7 +1640,7 @@ discard block |
||
1640 | 1640 | if (is_array($user_list) && is_array($group_list)) { |
1641 | 1641 | foreach ($group_list as $group_id) { |
1642 | 1642 | foreach ($user_list as $user_id) { |
1643 | - $role = self::get_user_group_role($user_id,$group_id); |
|
1643 | + $role = self::get_user_group_role($user_id, $group_id); |
|
1644 | 1644 | if ($role == 0) { |
1645 | 1645 | $sql = "INSERT INTO $table_url_rel_group |
1646 | 1646 | SET |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | public function delete_user_rel_group($user_id, $group_id) |
1672 | 1672 | { |
1673 | 1673 | $table = $this->usergroup_rel_user_table; |
1674 | - $sql= "DELETE FROM $table |
|
1674 | + $sql = "DELETE FROM $table |
|
1675 | 1675 | WHERE |
1676 | 1676 | user_id = ".intval($user_id)." AND |
1677 | 1677 | usergroup_id = ".intval($group_id)." "; |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | |
1728 | 1728 | $sql = "UPDATE $table_group_rel_user |
1729 | 1729 | SET relation_type = ".intval($relation_type)." |
1730 | - WHERE user_id = $user_id AND usergroup_id = $group_id" ; |
|
1730 | + WHERE user_id = $user_id AND usergroup_id = $group_id"; |
|
1731 | 1731 | Database::query($sql); |
1732 | 1732 | } |
1733 | 1733 | |
@@ -1769,7 +1769,7 @@ discard block |
||
1769 | 1769 | if (Database::num_rows($result) > 0) { |
1770 | 1770 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
1771 | 1771 | if ($with_image) { |
1772 | - $picture = self::get_picture_group($row['id'], $row['picture'],80); |
|
1772 | + $picture = self::get_picture_group($row['id'], $row['picture'], 80); |
|
1773 | 1773 | $img = '<img src="'.$picture['file'].'" />'; |
1774 | 1774 | $row['picture'] = $img; |
1775 | 1775 | } |
@@ -1805,11 +1805,11 @@ discard block |
||
1805 | 1805 | ORDER BY count DESC |
1806 | 1806 | LIMIT $num"; |
1807 | 1807 | |
1808 | - $result=Database::query($sql); |
|
1808 | + $result = Database::query($sql); |
|
1809 | 1809 | $array = array(); |
1810 | 1810 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
1811 | 1811 | if ($with_image) { |
1812 | - $picture = self::get_picture_group($row['id'], $row['picture'],80); |
|
1812 | + $picture = self::get_picture_group($row['id'], $row['picture'], 80); |
|
1813 | 1813 | $img = '<img src="'.$picture['file'].'" />'; |
1814 | 1814 | $row['picture'] = $img; |
1815 | 1815 | } |
@@ -1854,11 +1854,11 @@ discard block |
||
1854 | 1854 | ORDER BY created_at DESC |
1855 | 1855 | LIMIT $num "; |
1856 | 1856 | |
1857 | - $result=Database::query($sql); |
|
1857 | + $result = Database::query($sql); |
|
1858 | 1858 | $array = array(); |
1859 | 1859 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
1860 | 1860 | if ($with_image) { |
1861 | - $picture = self::get_picture_group($row['id'], $row['picture'],80); |
|
1861 | + $picture = self::get_picture_group($row['id'], $row['picture'], 80); |
|
1862 | 1862 | $img = '<img src="'.$picture['file'].'" />'; |
1863 | 1863 | $row['picture'] = $img; |
1864 | 1864 | } |
@@ -1892,7 +1892,7 @@ discard block |
||
1892 | 1892 | $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
1893 | 1893 | $group_id = intval($group_id); |
1894 | 1894 | |
1895 | - if (empty($group_id)){ |
|
1895 | + if (empty($group_id)) { |
|
1896 | 1896 | return array(); |
1897 | 1897 | } |
1898 | 1898 | |
@@ -1907,9 +1907,9 @@ discard block |
||
1907 | 1907 | $where_relation_condition = ''; |
1908 | 1908 | } else { |
1909 | 1909 | $new_relation_type = array(); |
1910 | - foreach($relation_type as $rel) { |
|
1910 | + foreach ($relation_type as $rel) { |
|
1911 | 1911 | $rel = intval($rel); |
1912 | - $new_relation_type[] ="'$rel'"; |
|
1912 | + $new_relation_type[] = "'$rel'"; |
|
1913 | 1913 | } |
1914 | 1914 | $relation_type = implode(',', $new_relation_type); |
1915 | 1915 | if (!empty($relation_type)) |
@@ -1953,7 +1953,7 @@ discard block |
||
1953 | 1953 | $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
1954 | 1954 | $group_id = intval($group_id); |
1955 | 1955 | |
1956 | - if (empty($group_id)){ |
|
1956 | + if (empty($group_id)) { |
|
1957 | 1957 | return array(); |
1958 | 1958 | } |
1959 | 1959 | |
@@ -1964,7 +1964,7 @@ discard block |
||
1964 | 1964 | WHERE gu.usergroup_id= $group_id |
1965 | 1965 | ORDER BY relation_type, firstname"; |
1966 | 1966 | |
1967 | - $result=Database::query($sql); |
|
1967 | + $result = Database::query($sql); |
|
1968 | 1968 | $array = array(); |
1969 | 1969 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
1970 | 1970 | $array[$row['id']] = $row; |
@@ -1993,27 +1993,27 @@ discard block |
||
1993 | 1993 | case GROUP_USER_PERMISSION_READER: |
1994 | 1994 | // I'm just a reader |
1995 | 1995 | $relation_group_title = get_lang('IAmAReader'); |
1996 | - $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
1997 | - Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>'; |
|
1998 | - $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
1996 | + $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
1997 | + Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show == 'invite_friends' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>'; |
|
1998 | + $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
1999 | 1999 | Display::return_icon('group_leave.png', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>'; |
2000 | 2000 | break; |
2001 | 2001 | case GROUP_USER_PERMISSION_ADMIN: |
2002 | 2002 | $relation_group_title = get_lang('IAmAnAdmin'); |
2003 | - $links .= '<li><a href="group_edit.php?id='.$group_id.'">'. |
|
2004 | - Display::return_icon('group_edit.png', get_lang('EditGroup'), array('hspace'=>'6')).'<span class="'.($show=='group_edit'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('EditGroup').'</span></a></li>'; |
|
2005 | - $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'. |
|
2006 | - Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show=='waiting_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>'; |
|
2007 | - $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
2008 | - Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>'; |
|
2009 | - $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2003 | + $links .= '<li><a href="group_edit.php?id='.$group_id.'">'. |
|
2004 | + Display::return_icon('group_edit.png', get_lang('EditGroup'), array('hspace'=>'6')).'<span class="'.($show == 'group_edit' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('EditGroup').'</span></a></li>'; |
|
2005 | + $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'. |
|
2006 | + Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show == 'waiting_list' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>'; |
|
2007 | + $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
2008 | + Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show == 'invite_friends' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>'; |
|
2009 | + $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2010 | 2010 | Display::return_icon('group_leave.png', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>'; |
2011 | 2011 | break; |
2012 | 2012 | case GROUP_USER_PERMISSION_PENDING_INVITATION: |
2013 | 2013 | // $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>'; |
2014 | 2014 | break; |
2015 | 2015 | case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER: |
2016 | - $relation_group_title = get_lang('WaitingForAdminResponse'); |
|
2016 | + $relation_group_title = get_lang('WaitingForAdminResponse'); |
|
2017 | 2017 | break; |
2018 | 2018 | case GROUP_USER_PERMISSION_MODERATOR: |
2019 | 2019 | $relation_group_title = get_lang('IAmAModerator'); |
@@ -2021,25 +2021,25 @@ discard block |
||
2021 | 2021 | //$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>'; |
2022 | 2022 | //$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>'; |
2023 | 2023 | if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) { |
2024 | - $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'. |
|
2025 | - Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show=='waiting_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>'; |
|
2024 | + $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'. |
|
2025 | + Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show == 'waiting_list' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>'; |
|
2026 | 2026 | } |
2027 | - $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
2028 | - Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>'; |
|
2029 | - $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2027 | + $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
2028 | + Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show == 'invite_friends' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>'; |
|
2029 | + $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2030 | 2030 | Display::return_icon('group_leave.png', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>'; |
2031 | 2031 | break; |
2032 | 2032 | case GROUP_USER_PERMISSION_HRM: |
2033 | 2033 | $relation_group_title = get_lang('IAmAHRM'); |
2034 | 2034 | $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').'">'. |
2035 | 2035 | Display::return_icon('new-message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('NewTopic').'</span></a></li>'; |
2036 | - $links .= '<li><a href="group_view.php?id='.$group_id.'">'. |
|
2037 | - 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>'; |
|
2038 | - $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
2039 | - Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>'; |
|
2040 | - $links .= '<li><a href="group_members.php?id='.$group_id.'">'. |
|
2041 | - 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>'; |
|
2042 | - $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2036 | + $links .= '<li><a href="group_view.php?id='.$group_id.'">'. |
|
2037 | + 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>'; |
|
2038 | + $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'. |
|
2039 | + Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show == 'invite_friends' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>'; |
|
2040 | + $links .= '<li><a href="group_members.php?id='.$group_id.'">'. |
|
2041 | + 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>'; |
|
2042 | + $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'. |
|
2043 | 2043 | Display::return_icon('delete_data.gif', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>'; |
2044 | 2044 | break; |
2045 | 2045 | default: |
@@ -2082,14 +2082,14 @@ discard block |
||
2082 | 2082 | */ |
2083 | 2083 | public function get_groups_by_user_count($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) |
2084 | 2084 | { |
2085 | - $table_group_rel_user = $this->usergroup_rel_user_table; |
|
2086 | - $tbl_group = $this->table; |
|
2087 | - $user_id = intval($user_id); |
|
2085 | + $table_group_rel_user = $this->usergroup_rel_user_table; |
|
2086 | + $tbl_group = $this->table; |
|
2087 | + $user_id = intval($user_id); |
|
2088 | 2088 | |
2089 | 2089 | if ($relation_type == 0) { |
2090 | 2090 | $where_relation_condition = ''; |
2091 | 2091 | } else { |
2092 | - $relation_type = intval($relation_type); |
|
2092 | + $relation_type = intval($relation_type); |
|
2093 | 2093 | $where_relation_condition = "AND gu.relation_type = $relation_type "; |
2094 | 2094 | } |
2095 | 2095 | |
@@ -2162,7 +2162,7 @@ discard block |
||
2162 | 2162 | } |
2163 | 2163 | |
2164 | 2164 | $direction = 'ASC'; |
2165 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
2165 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
2166 | 2166 | $direction = 'ASC'; |
2167 | 2167 | } |
2168 | 2168 | |
@@ -2173,8 +2173,8 @@ discard block |
||
2173 | 2173 | $sql .= " LIMIT $from,$number_of_items"; |
2174 | 2174 | |
2175 | 2175 | $res = Database::query($sql); |
2176 | - if (Database::num_rows($res)> 0) { |
|
2177 | - while ($row = Database::fetch_array($res,'ASSOC')) { |
|
2176 | + if (Database::num_rows($res) > 0) { |
|
2177 | + while ($row = Database::fetch_array($res, 'ASSOC')) { |
|
2178 | 2178 | if (!in_array($row['id'], $return)) { |
2179 | 2179 | $return[$row['id']] = $row; |
2180 | 2180 | } |
@@ -2199,7 +2199,7 @@ discard block |
||
2199 | 2199 | if ($i == $max_level) { |
2200 | 2200 | $select_part .= "rg$rg_number.group_id as id_$rg_number "; |
2201 | 2201 | } else { |
2202 | - $select_part .="rg$rg_number.group_id as id_$rg_number, "; |
|
2202 | + $select_part .= "rg$rg_number.group_id as id_$rg_number, "; |
|
2203 | 2203 | } |
2204 | 2204 | if ($i == 1) { |
2205 | 2205 | $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id "; |
@@ -2387,7 +2387,7 @@ discard block |
||
2387 | 2387 | $nameList = '<ul class="list-unstyled">'; |
2388 | 2388 | |
2389 | 2389 | foreach ($groupsNameListParsed as $name) { |
2390 | - $nameList .= '<li>' . Display::span($name, ['class' => 'label label-info']) . '</li>'; |
|
2390 | + $nameList .= '<li>'.Display::span($name, ['class' => 'label label-info']).'</li>'; |
|
2391 | 2391 | } |
2392 | 2392 | |
2393 | 2393 | $nameList .= '</ul>'; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * @return bool|mixed |
|
89 | + * @return string |
|
90 | 90 | */ |
91 | 91 | public static function getPasswordEncryption() |
92 | 92 | { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param string $raw |
162 | 162 | * @param User $user |
163 | 163 | * |
164 | - * @return bool |
|
164 | + * @return string |
|
165 | 165 | */ |
166 | 166 | public static function encryptPassword($raw, User $user) |
167 | 167 | { |
@@ -965,6 +965,7 @@ discard block |
||
965 | 965 | * Disables or enables a user |
966 | 966 | * @param int user_id |
967 | 967 | * @param int Enable or disable |
968 | + * @param integer $active |
|
968 | 969 | * @return void |
969 | 970 | * @assert (-1,0) === false |
970 | 971 | * @assert (1,1) === true |
@@ -995,6 +996,7 @@ discard block |
||
995 | 996 | /** |
996 | 997 | * Disables a user |
997 | 998 | * @param int User id |
999 | + * @param integer $user_id |
|
998 | 1000 | * @return bool |
999 | 1001 | * @uses UserManager::change_active_state() to actually disable the user |
1000 | 1002 | * @assert (0) === false |
@@ -1011,6 +1013,7 @@ discard block |
||
1011 | 1013 | /** |
1012 | 1014 | * Enable a user |
1013 | 1015 | * @param int User id |
1016 | + * @param integer $user_id |
|
1014 | 1017 | * @return bool |
1015 | 1018 | * @uses UserManager::change_active_state() to actually disable the user |
1016 | 1019 | * @assert (0) === false |
@@ -1175,6 +1178,7 @@ discard block |
||
1175 | 1178 | * Checks whether the user id exists in the database |
1176 | 1179 | * |
1177 | 1180 | * @param int User id |
1181 | + * @param integer $userId |
|
1178 | 1182 | * @return bool True if user id was found, false otherwise |
1179 | 1183 | */ |
1180 | 1184 | public static function is_user_id_valid($userId) |
@@ -1357,7 +1361,7 @@ discard block |
||
1357 | 1361 | * @param array $userInfo user information to avoid query the DB |
1358 | 1362 | * returns the /main/img/unknown.jpg image set it at true |
1359 | 1363 | * |
1360 | - * @return array Array of 2 elements: 'dir' and 'file' which contain |
|
1364 | + * @return integer Array of 2 elements: 'dir' and 'file' which contain |
|
1361 | 1365 | * the dir and file as the name implies if image does not exist it will |
1362 | 1366 | * return the unknow image if anonymous parameter is true if not it returns an empty array |
1363 | 1367 | */ |
@@ -1729,7 +1733,7 @@ discard block |
||
1729 | 1733 | * @param int $user_id User id |
1730 | 1734 | * @param $force Optional parameter to force building after a removal request |
1731 | 1735 | * |
1732 | - * @return A string containing the XHTML code to dipslay the production list, or FALSE |
|
1736 | + * @return boolean|string string containing the XHTML code to dipslay the production list, or FALSE |
|
1733 | 1737 | */ |
1734 | 1738 | public static function build_production_list($user_id, $force = false, $showdelete = false) |
1735 | 1739 | { |
@@ -1765,7 +1769,7 @@ discard block |
||
1765 | 1769 | /** |
1766 | 1770 | * Returns an array with the user's productions. |
1767 | 1771 | * |
1768 | - * @param $user_id User id |
|
1772 | + * @param integer $user_id User id |
|
1769 | 1773 | * @return array An array containing the user's productions |
1770 | 1774 | */ |
1771 | 1775 | public static function get_user_productions($user_id) |
@@ -1920,7 +1924,7 @@ discard block |
||
1920 | 1924 | |
1921 | 1925 | /** |
1922 | 1926 | * Build a list of extra file already uploaded in $user_folder/{$extra_field}/ |
1923 | - * @param $user_id |
|
1927 | + * @param integer $user_id |
|
1924 | 1928 | * @param $extra_field |
1925 | 1929 | * @param bool $force |
1926 | 1930 | * @param bool $showdelete |
@@ -2023,7 +2027,7 @@ discard block |
||
2023 | 2027 | * @param int $fieldType Field's type |
2024 | 2028 | * @param string $displayText Field's language var name |
2025 | 2029 | * @param string $default Field's default value |
2026 | - * @return int |
|
2030 | + * @return boolean |
|
2027 | 2031 | */ |
2028 | 2032 | public static function create_extra_field($variable, $fieldType, $displayText, $default) |
2029 | 2033 | { |
@@ -2056,6 +2060,7 @@ discard block |
||
2056 | 2060 | * @param boolean Whether to prefix the fields indexes with "extra_" (might be used by formvalidator) |
2057 | 2061 | * @param boolean Whether to return invisible fields as well |
2058 | 2062 | * @param boolean Whether to split multiple-selection fields or not |
2063 | + * @param boolean $field_filter |
|
2059 | 2064 | * @return array Array of fields => value for the given user |
2060 | 2065 | */ |
2061 | 2066 | public static function get_extra_user_data( |
@@ -2242,7 +2247,6 @@ discard block |
||
2242 | 2247 | /** |
2243 | 2248 | * Get all the extra field information of a certain field (also the options) |
2244 | 2249 | * |
2245 | - * @param int $field_name the name of the field we want to know everything of |
|
2246 | 2250 | * @return array $return containing all th information about the extra profile field |
2247 | 2251 | * @author Julio Montoya |
2248 | 2252 | * @deprecated |
@@ -2285,6 +2289,7 @@ discard block |
||
2285 | 2289 | /** |
2286 | 2290 | * Get extra user data by field variable |
2287 | 2291 | * @param string field variable |
2292 | + * @param string $field_variable |
|
2288 | 2293 | * @return array data |
2289 | 2294 | */ |
2290 | 2295 | public static function get_extra_user_data_by_field_variable($field_variable) |
@@ -2829,7 +2834,7 @@ discard block |
||
2829 | 2834 | * @param string User ID |
2830 | 2835 | * @param string course directory |
2831 | 2836 | * @param string resourcetype: images, all |
2832 | - * @return int User ID (or false if not found) |
|
2837 | + * @return string User ID (or false if not found) |
|
2833 | 2838 | */ |
2834 | 2839 | public static function get_user_upload_files_by_course($user_id, $course, $resourcetype = 'all') |
2835 | 2840 | { |
@@ -2909,7 +2914,7 @@ discard block |
||
2909 | 2914 | /** |
2910 | 2915 | * Adds a new API key to the users' account |
2911 | 2916 | * @param int Optional user ID (defaults to the results of api_get_user_id()) |
2912 | - * @return boolean True on success, false on failure |
|
2917 | + * @return false|string True on success, false on failure |
|
2913 | 2918 | */ |
2914 | 2919 | public static function add_api_key($user_id = null, $api_service = 'dokeos') |
2915 | 2920 | { |
@@ -2964,6 +2969,7 @@ discard block |
||
2964 | 2969 | * Regenerate an API key from the user's account |
2965 | 2970 | * @param int user ID (defaults to the results of api_get_user_id()) |
2966 | 2971 | * @param string API key's internal ID |
2972 | + * @param string $api_service |
|
2967 | 2973 | * @return int num |
2968 | 2974 | */ |
2969 | 2975 | public static function update_api_key($user_id, $api_service) |
@@ -2993,6 +2999,7 @@ discard block |
||
2993 | 2999 | /** |
2994 | 3000 | * @param int user ID (defaults to the results of api_get_user_id()) |
2995 | 3001 | * @param string API key's internal ID |
3002 | + * @param string $api_service |
|
2996 | 3003 | * @return int row ID, or return false if not found |
2997 | 3004 | */ |
2998 | 3005 | public static function get_api_key_id($user_id, $api_service) |
@@ -3204,7 +3211,8 @@ discard block |
||
3204 | 3211 | * @param int user_id |
3205 | 3212 | * @param int field_id |
3206 | 3213 | * @param bool show links or not |
3207 | - * @return array |
|
3214 | + * @param integer $user_id |
|
3215 | + * @return string |
|
3208 | 3216 | */ |
3209 | 3217 | public static function get_user_tags_to_string($user_id, $field_id, $show_links = true) |
3210 | 3218 | { |
@@ -3249,6 +3257,8 @@ discard block |
||
3249 | 3257 | * Get the tag id |
3250 | 3258 | * @param int tag |
3251 | 3259 | * @param int field_id |
3260 | + * @param string $tag |
|
3261 | + * @param integer $field_id |
|
3252 | 3262 | * @return int returns 0 if fails otherwise the tag id |
3253 | 3263 | */ |
3254 | 3264 | public static function get_tag_id($tag, $field_id) |
@@ -3295,7 +3305,7 @@ discard block |
||
3295 | 3305 | * @param mixed tag |
3296 | 3306 | * @param int The user id |
3297 | 3307 | * @param int field id of the tag |
3298 | - * @return bool |
|
3308 | + * @return boolean|null |
|
3299 | 3309 | */ |
3300 | 3310 | public static function add_tag($tag, $user_id, $field_id) |
3301 | 3311 | { |
@@ -4101,7 +4111,7 @@ discard block |
||
4101 | 4111 | * Add subscribed users to a user by relation type |
4102 | 4112 | * @param int $userId The user id |
4103 | 4113 | * @param array $subscribedUsersId The id of suscribed users |
4104 | - * @param action $relationType The relation type |
|
4114 | + * @param integer $relationType The relation type |
|
4105 | 4115 | */ |
4106 | 4116 | public static function subscribeUsersToUser($userId, $subscribedUsersId, $relationType) |
4107 | 4117 | { |
@@ -4158,6 +4168,8 @@ discard block |
||
4158 | 4168 | * This function check if an user is followed by human resources manager |
4159 | 4169 | * @param int User id |
4160 | 4170 | * @param int Human resources manager |
4171 | + * @param integer $user_id |
|
4172 | + * @param integer $hr_dept_id |
|
4161 | 4173 | * @return bool |
4162 | 4174 | */ |
4163 | 4175 | public static function is_user_followed_by_drh($user_id, $hr_dept_id) |
@@ -4230,6 +4242,8 @@ discard block |
||
4230 | 4242 | * Determines if a user is a gradebook certified |
4231 | 4243 | * @param int The category id of gradebook |
4232 | 4244 | * @param int The user id |
4245 | + * @param integer $cat_id |
|
4246 | + * @param integer $user_id |
|
4233 | 4247 | * @return boolean |
4234 | 4248 | */ |
4235 | 4249 | public static function is_user_certified($cat_id, $user_id) |
@@ -4252,6 +4266,8 @@ discard block |
||
4252 | 4266 | * Gets the info about a gradebook certificate for a user by course |
4253 | 4267 | * @param string The course code |
4254 | 4268 | * @param int The user id |
4269 | + * @param integer $course_code |
|
4270 | + * @param integer $user_id |
|
4255 | 4271 | * @return array if there is not information return false |
4256 | 4272 | */ |
4257 | 4273 | public static function get_info_gradebook_certificate($course_code, $user_id) |
@@ -4715,7 +4731,7 @@ discard block |
||
4715 | 4731 | } |
4716 | 4732 | |
4717 | 4733 | /** |
4718 | - * @return array |
|
4734 | + * @return string[] |
|
4719 | 4735 | */ |
4720 | 4736 | static function get_user_field_types() |
4721 | 4737 | { |
@@ -4967,7 +4983,7 @@ discard block |
||
4967 | 4983 | * Get either a Gravatar URL or complete image tag for a specified email address. |
4968 | 4984 | * |
4969 | 4985 | * @param string $email The email address |
4970 | - * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ] |
|
4986 | + * @param integer $s Size in pixels, defaults to 80px [ 1 - 2048 ] |
|
4971 | 4987 | * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] |
4972 | 4988 | * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] |
4973 | 4989 | * @param boole $img True to return a complete IMG tag False for just the URL |
@@ -774,10 +774,12 @@ discard block |
||
774 | 774 | public static function update_openid($user_id, $openid) |
775 | 775 | { |
776 | 776 | $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
777 | - if ($user_id != strval(intval($user_id))) |
|
778 | - return false; |
|
779 | - if ($user_id === false) |
|
780 | - return false; |
|
777 | + if ($user_id != strval(intval($user_id))) { |
|
778 | + return false; |
|
779 | + } |
|
780 | + if ($user_id === false) { |
|
781 | + return false; |
|
782 | + } |
|
781 | 783 | $sql = "UPDATE $table_user SET |
782 | 784 | openid='".Database::escape_string($openid)."'"; |
783 | 785 | $sql .= " WHERE id= $user_id"; |
@@ -2069,8 +2071,9 @@ discard block |
||
2069 | 2071 | if (empty($user_id)) { |
2070 | 2072 | $user_id = 0; |
2071 | 2073 | } else { |
2072 | - if ($user_id != strval(intval($user_id))) |
|
2073 | - return array(); |
|
2074 | + if ($user_id != strval(intval($user_id))) { |
|
2075 | + return array(); |
|
2076 | + } |
|
2074 | 2077 | } |
2075 | 2078 | $extra_data = array(); |
2076 | 2079 | $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD); |
@@ -2162,8 +2165,9 @@ discard block |
||
2162 | 2165 | if (empty($user_id)) { |
2163 | 2166 | $user_id = 0; |
2164 | 2167 | } else { |
2165 | - if ($user_id != strval(intval($user_id))) |
|
2166 | - return array(); |
|
2168 | + if ($user_id != strval(intval($user_id))) { |
|
2169 | + return array(); |
|
2170 | + } |
|
2167 | 2171 | } |
2168 | 2172 | $extra_data = array(); |
2169 | 2173 | $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD); |
@@ -2880,13 +2884,15 @@ discard block |
||
2880 | 2884 | */ |
2881 | 2885 | public static function get_api_keys($user_id = null, $api_service = 'dokeos') |
2882 | 2886 | { |
2883 | - if ($user_id != strval(intval($user_id))) |
|
2884 | - return false; |
|
2887 | + if ($user_id != strval(intval($user_id))) { |
|
2888 | + return false; |
|
2889 | + } |
|
2885 | 2890 | if (empty($user_id)) { |
2886 | 2891 | $user_id = api_get_user_id(); |
2887 | 2892 | } |
2888 | - if ($user_id === false) |
|
2889 | - return false; |
|
2893 | + if ($user_id === false) { |
|
2894 | + return false; |
|
2895 | + } |
|
2890 | 2896 | $service_name = Database::escape_string($api_service); |
2891 | 2897 | if (is_string($service_name) === false) { |
2892 | 2898 | return false; |
@@ -2894,11 +2900,14 @@ discard block |
||
2894 | 2900 | $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY); |
2895 | 2901 | $sql = "SELECT * FROM $t_api WHERE user_id = $user_id AND api_service='$api_service';"; |
2896 | 2902 | $res = Database::query($sql); |
2897 | - if ($res === false) |
|
2898 | - return false; //error during query |
|
2903 | + if ($res === false) { |
|
2904 | + return false; |
|
2905 | + } |
|
2906 | + //error during query |
|
2899 | 2907 | $num = Database::num_rows($res); |
2900 | - if ($num == 0) |
|
2901 | - return false; |
|
2908 | + if ($num == 0) { |
|
2909 | + return false; |
|
2910 | + } |
|
2902 | 2911 | $list = array(); |
2903 | 2912 | while ($row = Database::fetch_array($res)) { |
2904 | 2913 | $list[$row['id']] = $row['api_key']; |
@@ -2913,13 +2922,15 @@ discard block |
||
2913 | 2922 | */ |
2914 | 2923 | public static function add_api_key($user_id = null, $api_service = 'dokeos') |
2915 | 2924 | { |
2916 | - if ($user_id != strval(intval($user_id))) |
|
2917 | - return false; |
|
2925 | + if ($user_id != strval(intval($user_id))) { |
|
2926 | + return false; |
|
2927 | + } |
|
2918 | 2928 | if (empty($user_id)) { |
2919 | 2929 | $user_id = api_get_user_id(); |
2920 | 2930 | } |
2921 | - if ($user_id === false) |
|
2922 | - return false; |
|
2931 | + if ($user_id === false) { |
|
2932 | + return false; |
|
2933 | + } |
|
2923 | 2934 | $service_name = Database::escape_string($api_service); |
2924 | 2935 | if (is_string($service_name) === false) { |
2925 | 2936 | return false; |
@@ -2928,8 +2939,10 @@ discard block |
||
2928 | 2939 | $md5 = md5((time() + ($user_id * 5)) - rand(10000, 10000)); //generate some kind of random key |
2929 | 2940 | $sql = "INSERT INTO $t_api (user_id, api_key,api_service) VALUES ($user_id,'$md5','$service_name')"; |
2930 | 2941 | $res = Database::query($sql); |
2931 | - if ($res === false) |
|
2932 | - return false; //error during query |
|
2942 | + if ($res === false) { |
|
2943 | + return false; |
|
2944 | + } |
|
2945 | + //error during query |
|
2933 | 2946 | $num = Database::insert_id(); |
2934 | 2947 | return ($num == 0) ? false : $num; |
2935 | 2948 | } |
@@ -2941,22 +2954,29 @@ discard block |
||
2941 | 2954 | */ |
2942 | 2955 | public static function delete_api_key($key_id) |
2943 | 2956 | { |
2944 | - if ($key_id != strval(intval($key_id))) |
|
2945 | - return false; |
|
2946 | - if ($key_id === false) |
|
2947 | - return false; |
|
2957 | + if ($key_id != strval(intval($key_id))) { |
|
2958 | + return false; |
|
2959 | + } |
|
2960 | + if ($key_id === false) { |
|
2961 | + return false; |
|
2962 | + } |
|
2948 | 2963 | $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY); |
2949 | 2964 | $sql = "SELECT * FROM $t_api WHERE id = ".$key_id; |
2950 | 2965 | $res = Database::query($sql); |
2951 | - if ($res === false) |
|
2952 | - return false; //error during query |
|
2966 | + if ($res === false) { |
|
2967 | + return false; |
|
2968 | + } |
|
2969 | + //error during query |
|
2953 | 2970 | $num = Database::num_rows($res); |
2954 | - if ($num !== 1) |
|
2955 | - return false; |
|
2971 | + if ($num !== 1) { |
|
2972 | + return false; |
|
2973 | + } |
|
2956 | 2974 | $sql = "DELETE FROM $t_api WHERE id = ".$key_id; |
2957 | 2975 | $res = Database::query($sql); |
2958 | - if ($res === false) |
|
2959 | - return false; //error during query |
|
2976 | + if ($res === false) { |
|
2977 | + return false; |
|
2978 | + } |
|
2979 | + //error during query |
|
2960 | 2980 | return true; |
2961 | 2981 | } |
2962 | 2982 | |
@@ -2968,10 +2988,12 @@ discard block |
||
2968 | 2988 | */ |
2969 | 2989 | public static function update_api_key($user_id, $api_service) |
2970 | 2990 | { |
2971 | - if ($user_id != strval(intval($user_id))) |
|
2972 | - return false; |
|
2973 | - if ($user_id === false) |
|
2974 | - return false; |
|
2991 | + if ($user_id != strval(intval($user_id))) { |
|
2992 | + return false; |
|
2993 | + } |
|
2994 | + if ($user_id === false) { |
|
2995 | + return false; |
|
2996 | + } |
|
2975 | 2997 | $service_name = Database::escape_string($api_service); |
2976 | 2998 | if (is_string($service_name) === false) { |
2977 | 2999 | return false; |
@@ -2997,12 +3019,15 @@ discard block |
||
2997 | 3019 | */ |
2998 | 3020 | public static function get_api_key_id($user_id, $api_service) |
2999 | 3021 | { |
3000 | - if ($user_id != strval(intval($user_id))) |
|
3001 | - return false; |
|
3002 | - if ($user_id === false) |
|
3003 | - return false; |
|
3004 | - if (empty($api_service)) |
|
3005 | - return false; |
|
3022 | + if ($user_id != strval(intval($user_id))) { |
|
3023 | + return false; |
|
3024 | + } |
|
3025 | + if ($user_id === false) { |
|
3026 | + return false; |
|
3027 | + } |
|
3028 | + if (empty($api_service)) { |
|
3029 | + return false; |
|
3030 | + } |
|
3006 | 3031 | $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY); |
3007 | 3032 | $api_service = Database::escape_string($api_service); |
3008 | 3033 | $sql = "SELECT id FROM $t_api WHERE user_id=".$user_id." AND api_service='".$api_service."'"; |
@@ -4473,8 +4498,9 @@ discard block |
||
4473 | 4498 | $form->applyFilter('extra_'.$field_details[1], 'stripslashes'); |
4474 | 4499 | $form->applyFilter('extra_'.$field_details[1], 'trim'); |
4475 | 4500 | if (!$admin_permissions) { |
4476 | - if ($field_details[7] == 0) |
|
4477 | - $form->freeze('extra_'.$field_details[1]); |
|
4501 | + if ($field_details[7] == 0) { |
|
4502 | + $form->freeze('extra_'.$field_details[1]); |
|
4503 | + } |
|
4478 | 4504 | } |
4479 | 4505 | break; |
4480 | 4506 | case ExtraField::FIELD_TYPE_RADIO: |
@@ -4491,8 +4517,9 @@ discard block |
||
4491 | 4517 | } |
4492 | 4518 | $form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], ''); |
4493 | 4519 | if (!$admin_permissions) { |
4494 | - if ($field_details[7] == 0) |
|
4495 | - $form->freeze('extra_'.$field_details[1]); |
|
4520 | + if ($field_details[7] == 0) { |
|
4521 | + $form->freeze('extra_'.$field_details[1]); |
|
4522 | + } |
|
4496 | 4523 | } |
4497 | 4524 | break; |
4498 | 4525 | case ExtraField::FIELD_TYPE_SELECT: |
@@ -4530,8 +4557,9 @@ discard block |
||
4530 | 4557 | ); |
4531 | 4558 | |
4532 | 4559 | if (!$admin_permissions) { |
4533 | - if ($field_details[7] == 0) |
|
4534 | - $form->freeze('extra_'.$field_details[1]); |
|
4560 | + if ($field_details[7] == 0) { |
|
4561 | + $form->freeze('extra_'.$field_details[1]); |
|
4562 | + } |
|
4535 | 4563 | } |
4536 | 4564 | break; |
4537 | 4565 | case ExtraField::FIELD_TYPE_SELECT_MULTIPLE: |
@@ -4547,8 +4575,9 @@ discard block |
||
4547 | 4575 | array('multiple' => 'multiple') |
4548 | 4576 | ); |
4549 | 4577 | if (!$admin_permissions) { |
4550 | - if ($field_details[7] == 0) |
|
4551 | - $form->freeze('extra_'.$field_details[1]); |
|
4578 | + if ($field_details[7] == 0) { |
|
4579 | + $form->freeze('extra_'.$field_details[1]); |
|
4580 | + } |
|
4552 | 4581 | } |
4553 | 4582 | break; |
4554 | 4583 | case ExtraField::FIELD_TYPE_DATE: |
@@ -4556,8 +4585,9 @@ discard block |
||
4556 | 4585 | $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); |
4557 | 4586 | $form->setDefaults($defaults); |
4558 | 4587 | if (!$admin_permissions) { |
4559 | - if ($field_details[7] == 0) |
|
4560 | - $form->freeze('extra_'.$field_details[1]); |
|
4588 | + if ($field_details[7] == 0) { |
|
4589 | + $form->freeze('extra_'.$field_details[1]); |
|
4590 | + } |
|
4561 | 4591 | } |
4562 | 4592 | $form->applyFilter('theme', 'trim'); |
4563 | 4593 | break; |
@@ -4566,8 +4596,9 @@ discard block |
||
4566 | 4596 | $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); |
4567 | 4597 | $form->setDefaults($defaults); |
4568 | 4598 | if (!$admin_permissions) { |
4569 | - if ($field_details[7] == 0) |
|
4570 | - $form->freeze('extra_'.$field_details[1]); |
|
4599 | + if ($field_details[7] == 0) { |
|
4600 | + $form->freeze('extra_'.$field_details[1]); |
|
4601 | + } |
|
4571 | 4602 | } |
4572 | 4603 | $form->applyFilter('theme', 'trim'); |
4573 | 4604 | break; |
@@ -4586,8 +4617,9 @@ discard block |
||
4586 | 4617 | $form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], ' '); |
4587 | 4618 | |
4588 | 4619 | if (!$admin_permissions) { |
4589 | - if ($field_details[7] == 0) |
|
4590 | - $form->freeze('extra_'.$field_details[1]); |
|
4620 | + if ($field_details[7] == 0) { |
|
4621 | + $form->freeze('extra_'.$field_details[1]); |
|
4622 | + } |
|
4591 | 4623 | } |
4592 | 4624 | |
4593 | 4625 | /* Recoding the selected values for double : if the user has |
@@ -4647,8 +4679,9 @@ discard block |
||
4647 | 4679 | break; |
4648 | 4680 | case ExtraField::FIELD_TYPE_TIMEZONE: |
4649 | 4681 | $form->addElement('select', 'extra_'.$field_details[1], $field_details[3], api_get_timezones(), ''); |
4650 | - if ($field_details[7] == 0) |
|
4651 | - $form->freeze('extra_'.$field_details[1]); |
|
4682 | + if ($field_details[7] == 0) { |
|
4683 | + $form->freeze('extra_'.$field_details[1]); |
|
4684 | + } |
|
4652 | 4685 | break; |
4653 | 4686 | case ExtraField::FIELD_TYPE_SOCIAL_PROFILE: |
4654 | 4687 | // get the social network's favicon |
@@ -4673,8 +4706,9 @@ discard block |
||
4673 | 4706 | ); |
4674 | 4707 | $form->applyFilter('extra_'.$field_details[1], 'stripslashes'); |
4675 | 4708 | $form->applyFilter('extra_'.$field_details[1], 'trim'); |
4676 | - if ($field_details[7] == 0) |
|
4677 | - $form->freeze('extra_'.$field_details[1]); |
|
4709 | + if ($field_details[7] == 0) { |
|
4710 | + $form->freeze('extra_'.$field_details[1]); |
|
4711 | + } |
|
4678 | 4712 | break; |
4679 | 4713 | case ExtraField::FIELD_TYPE_FILE: |
4680 | 4714 | $extra_field = 'extra_'.$field_details[1]; |
@@ -4991,8 +5025,9 @@ discard block |
||
4991 | 5025 | $url .= "?s=$s&d=$d&r=$r"; |
4992 | 5026 | if ( $img ) { |
4993 | 5027 | $url = '<img src="' . $url . '"'; |
4994 | - foreach ( $atts as $key => $val ) |
|
4995 | - $url .= ' ' . $key . '="' . $val . '"'; |
|
5028 | + foreach ( $atts as $key => $val ) { |
|
5029 | + $url .= ' ' . $key . '="' . $val . '"'; |
|
5030 | + } |
|
4996 | 5031 | $url .= ' />'; |
4997 | 5032 | } |
4998 | 5033 | return $url; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | const USER_FIELD_TYPE_TIMEZONE = 11; |
35 | 35 | const USER_FIELD_TYPE_SOCIAL_PROFILE = 12; |
36 | 36 | const USER_FIELD_TYPE_FILE = 13; |
37 | - const USER_FIELD_TYPE_MOBILE_PHONE_NUMBER = 14; |
|
37 | + const USER_FIELD_TYPE_MOBILE_PHONE_NUMBER = 14; |
|
38 | 38 | |
39 | 39 | private static $encryptionMethod; |
40 | 40 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | if (empty($password)) { |
283 | - Display::addFlash(Display::return_message(get_lang('ThisFieldIsRequired').': '.get_lang('Password') , 'warning')); |
|
283 | + Display::addFlash(Display::return_message(get_lang('ThisFieldIsRequired').': '.get_lang('Password'), 'warning')); |
|
284 | 284 | |
285 | 285 | return false; |
286 | 286 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $res = Database::query($sql); |
495 | 495 | while ($course = Database::fetch_object($res)) { |
496 | 496 | $sql = "SELECT id FROM $table_course_user |
497 | - WHERE status=1 AND c_id = " . intval($course->c_id); |
|
497 | + WHERE status=1 AND c_id = ".intval($course->c_id); |
|
498 | 498 | $res2 = Database::query($sql); |
499 | 499 | if (Database::num_rows($res2) == 1) { |
500 | 500 | |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | $sql = "UPDATE $table_user SET active = 1 WHERE id IN ($ids)"; |
759 | 759 | $r = Database::query($sql); |
760 | 760 | if ($r !== false) { |
761 | - Event::addEvent(LOG_USER_ENABLE,LOG_USER_ID,$ids); |
|
761 | + Event::addEvent(LOG_USER_ENABLE, LOG_USER_ID, $ids); |
|
762 | 762 | } |
763 | 763 | return $r; |
764 | 764 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | // 1. Conversion of unacceptable letters (latinian letters with accents for example) into ASCII letters in order they not to be totally removed. |
1165 | 1165 | // 2. Applying the strict purifier. |
1166 | 1166 | // 3. Length limitation. |
1167 | - $return = api_get_setting('login_is_email') == 'true' ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, USERNAME_MAX_LENGTH); |
|
1167 | + $return = api_get_setting('login_is_email') == 'true' ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, USERNAME_MAX_LENGTH); |
|
1168 | 1168 | $return = URLify::transliterate($return); |
1169 | 1169 | return $return; |
1170 | 1170 | } |
@@ -1256,12 +1256,12 @@ discard block |
||
1256 | 1256 | |
1257 | 1257 | if (!is_null($order)) { |
1258 | 1258 | $order = Database::escape_string($order); |
1259 | - $sql .= ' ORDER BY ' . $order; |
|
1259 | + $sql .= ' ORDER BY '.$order; |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | if (!is_null($limit)) { |
1263 | 1263 | $limit = Database::escape_string($limit); |
1264 | - $sql .= ' LIMIT ' . $limit; |
|
1264 | + $sql .= ' LIMIT '.$limit; |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | $rs = Database::query($sql); |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | // In exceptional cases, on some portals, the intermediate base user |
1444 | 1444 | // directory might not have been created. Make sure it is before |
1445 | 1445 | // going further. |
1446 | - $rootPath = api_get_path(SYS_UPLOAD_PATH) . 'users/' . substr((string) $id, 0, 1); |
|
1446 | + $rootPath = api_get_path(SYS_UPLOAD_PATH).'users/'.substr((string) $id, 0, 1); |
|
1447 | 1447 | if (!is_dir($rootPath)) { |
1448 | 1448 | $perm = api_get_permissions_for_new_directories(); |
1449 | 1449 | try { |
@@ -1695,7 +1695,7 @@ discard block |
||
1695 | 1695 | $path_info = self::get_user_picture_path_by_id($user_id, 'system'); |
1696 | 1696 | $path = $path_info['dir']; |
1697 | 1697 | if (!empty($extra_field)) { |
1698 | - $path .= $extra_field . '/'; |
|
1698 | + $path .= $extra_field.'/'; |
|
1699 | 1699 | } |
1700 | 1700 | // If this directory does not exist - we create it. |
1701 | 1701 | if (!file_exists($path)) { |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | } |
1704 | 1704 | |
1705 | 1705 | if (filter_extension($file)) { |
1706 | - if (@move_uploaded_file($source_file,$path.$file)) { |
|
1706 | + if (@move_uploaded_file($source_file, $path.$file)) { |
|
1707 | 1707 | if ($extra_field) { |
1708 | 1708 | return $extra_field.'/'.$file; |
1709 | 1709 | } else { |
@@ -1956,10 +1956,10 @@ discard block |
||
1956 | 1956 | if (count($extra_files) > 0) { |
1957 | 1957 | $extra_file_list = '<div class="files-production"><ul id="productions">'; |
1958 | 1958 | foreach ($extra_files as $file) { |
1959 | - $filename = substr($file,strlen($extra_field)+1); |
|
1959 | + $filename = substr($file, strlen($extra_field) + 1); |
|
1960 | 1960 | $extra_file_list .= '<li>'.Display::return_icon('archive.png').'<a href="'.$path.$extra_field.'/'.urlencode($filename).'" target="_blank">'.htmlentities($filename).'</a> '; |
1961 | 1961 | if ($showdelete) { |
1962 | - $extra_file_list .= '<input style="width:16px;" type="image" name="remove_extra_' . $extra_field . '['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($filename).'" onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>'; |
|
1962 | + $extra_file_list .= '<input style="width:16px;" type="image" name="remove_extra_'.$extra_field.'['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($filename).'" onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>'; |
|
1963 | 1963 | } |
1964 | 1964 | } |
1965 | 1965 | $extra_file_list .= '</ul></div>'; |
@@ -2544,7 +2544,7 @@ discard block |
||
2544 | 2544 | |
2545 | 2545 | if (api_is_allowed_to_create_course()) { |
2546 | 2546 | $sessionListFromCourseCoach = array(); |
2547 | - $sql =" SELECT DISTINCT session_id |
|
2547 | + $sql = " SELECT DISTINCT session_id |
|
2548 | 2548 | FROM $tbl_session_course_user |
2549 | 2549 | WHERE user_id = $user_id AND status = 2 "; |
2550 | 2550 | |
@@ -2552,7 +2552,7 @@ discard block |
||
2552 | 2552 | if (Database::num_rows($result)) { |
2553 | 2553 | $result = Database::store_result($result); |
2554 | 2554 | foreach ($result as $session) { |
2555 | - $sessionListFromCourseCoach[]= $session['session_id']; |
|
2555 | + $sessionListFromCourseCoach[] = $session['session_id']; |
|
2556 | 2556 | } |
2557 | 2557 | } |
2558 | 2558 | if (!empty($sessionListFromCourseCoach)) { |
@@ -2575,7 +2575,7 @@ discard block |
||
2575 | 2575 | ORDER BY access_start_date, access_end_date, name"; |
2576 | 2576 | |
2577 | 2577 | $result = Database::query($sql); |
2578 | - if (Database::num_rows($result)>0) { |
|
2578 | + if (Database::num_rows($result) > 0) { |
|
2579 | 2579 | while ($row = Database::fetch_assoc($result)) { |
2580 | 2580 | $sessions[$row['id']] = $row; |
2581 | 2581 | } |
@@ -2591,7 +2591,7 @@ discard block |
||
2591 | 2591 | ORDER BY access_start_date, access_end_date, name"; |
2592 | 2592 | |
2593 | 2593 | $result = Database::query($sql); |
2594 | - if (Database::num_rows($result)>0) { |
|
2594 | + if (Database::num_rows($result) > 0) { |
|
2595 | 2595 | while ($row = Database::fetch_assoc($result)) { |
2596 | 2596 | if (empty($sessions[$row['id']])) { |
2597 | 2597 | $sessions[$row['id']] = $row; |
@@ -3583,13 +3583,13 @@ discard block |
||
3583 | 3583 | $useExtraFields = false; |
3584 | 3584 | $extraFields = UserManager::get_extra_filtrable_fields(); |
3585 | 3585 | $extraFieldResult = array(); |
3586 | - if (is_array($extraFields) && count($extraFields)>0 ) { |
|
3586 | + if (is_array($extraFields) && count($extraFields) > 0) { |
|
3587 | 3587 | foreach ($extraFields as $extraField) { |
3588 | 3588 | $varName = 'field_'.$extraField['variable']; |
3589 | 3589 | //if (UserManager::is_extra_field_available($extraField['variable'])) { |
3590 | - if (isset($_GET[$varName]) && $_GET[$varName]!='0') { |
|
3590 | + if (isset($_GET[$varName]) && $_GET[$varName] != '0') { |
|
3591 | 3591 | $useExtraFields = true; |
3592 | - $extraFieldResult[]= UserManager::get_extra_user_data_by_value( |
|
3592 | + $extraFieldResult[] = UserManager::get_extra_user_data_by_value( |
|
3593 | 3593 | $extraField['variable'], |
3594 | 3594 | $_GET[$varName] |
3595 | 3595 | ); |
@@ -3600,17 +3600,17 @@ discard block |
||
3600 | 3600 | |
3601 | 3601 | if ($useExtraFields) { |
3602 | 3602 | $finalResult = array(); |
3603 | - if (count($extraFieldResult)>1) { |
|
3604 | - for ($i=0; $i < count($extraFieldResult) -1; $i++) { |
|
3605 | - if (is_array($extraFieldResult[$i]) && is_array($extraFieldResult[$i+1])) { |
|
3606 | - $finalResult = array_intersect($extraFieldResult[$i], $extraFieldResult[$i+1]); |
|
3603 | + if (count($extraFieldResult) > 1) { |
|
3604 | + for ($i = 0; $i < count($extraFieldResult) - 1; $i++) { |
|
3605 | + if (is_array($extraFieldResult[$i]) && is_array($extraFieldResult[$i + 1])) { |
|
3606 | + $finalResult = array_intersect($extraFieldResult[$i], $extraFieldResult[$i + 1]); |
|
3607 | 3607 | } |
3608 | 3608 | } |
3609 | 3609 | } else { |
3610 | 3610 | $finalResult = $extraFieldResult[0]; |
3611 | 3611 | } |
3612 | 3612 | |
3613 | - if (is_array($finalResult) && count($finalResult)>0) { |
|
3613 | + if (is_array($finalResult) && count($finalResult) > 0) { |
|
3614 | 3614 | $whereFilter = " AND u.id IN ('".implode("','", $finalResult)."') "; |
3615 | 3615 | } else { |
3616 | 3616 | //no results |
@@ -3787,7 +3787,7 @@ discard block |
||
3787 | 3787 | $sql = 'DELETE FROM '.$tbl_my_friend.' |
3788 | 3788 | WHERE relation_type <> '.USER_RELATION_TYPE_RRHH.' AND friend_user_id='.$friend_id.' '.$extra_condition; |
3789 | 3789 | Database::query($sql); |
3790 | - $sql= 'DELETE FROM '.$tbl_my_friend.' |
|
3790 | + $sql = 'DELETE FROM '.$tbl_my_friend.' |
|
3791 | 3791 | WHERE relation_type <> '.USER_RELATION_TYPE_RRHH.' AND user_id='.$friend_id.' '.$extra_condition; |
3792 | 3792 | Database::query($sql); |
3793 | 3793 | } else { |
@@ -3988,7 +3988,7 @@ discard block |
||
3988 | 3988 | |
3989 | 3989 | if (!empty($lastConnectionDate)) { |
3990 | 3990 | $lastConnectionDate = Database::escape_string($lastConnectionDate); |
3991 | - $userConditions .= " AND u.last_login <= '$lastConnectionDate' "; |
|
3991 | + $userConditions .= " AND u.last_login <= '$lastConnectionDate' "; |
|
3992 | 3992 | } |
3993 | 3993 | |
3994 | 3994 | $courseConditions = null; |
@@ -4055,7 +4055,7 @@ discard block |
||
4055 | 4055 | break; |
4056 | 4056 | case STUDENT_BOSS : |
4057 | 4057 | $drhConditions = " AND friend_user_id = $userId AND " |
4058 | - . "relation_type = " . USER_RELATION_TYPE_BOSS; |
|
4058 | + . "relation_type = ".USER_RELATION_TYPE_BOSS; |
|
4059 | 4059 | break; |
4060 | 4060 | } |
4061 | 4061 | |
@@ -4146,7 +4146,7 @@ discard block |
||
4146 | 4146 | WHERE |
4147 | 4147 | friend_user_id = $userId AND |
4148 | 4148 | relation_type = $relationType AND |
4149 | - access_url_id = " . api_get_current_access_url_id(); |
|
4149 | + access_url_id = ".api_get_current_access_url_id(); |
|
4150 | 4150 | } else { |
4151 | 4151 | $sql = "SELECT user_id FROM $userRelUserTable |
4152 | 4152 | WHERE friend_user_id = $userId |
@@ -4428,7 +4428,7 @@ discard block |
||
4428 | 4428 | if (empty($years)) { |
4429 | 4429 | $years = 1; |
4430 | 4430 | } |
4431 | - $inactive_time = $years * 31536000; //1 year |
|
4431 | + $inactive_time = $years * 31536000; //1 year |
|
4432 | 4432 | $rs = Database::query($sql); |
4433 | 4433 | if (Database::num_rows($rs) > 0) { |
4434 | 4434 | if ($last_login_date = Database::result($rs, 0, 0)) { |
@@ -4561,7 +4561,7 @@ discard block |
||
4561 | 4561 | 'extra_'.$field_details[1], |
4562 | 4562 | $field_details[3], |
4563 | 4563 | $options, |
4564 | - array('id' => 'extra_' . $field_details[1]) |
|
4564 | + array('id' => 'extra_'.$field_details[1]) |
|
4565 | 4565 | ); |
4566 | 4566 | |
4567 | 4567 | if (!$admin_permissions) { |
@@ -4715,7 +4715,7 @@ discard block |
||
4715 | 4715 | $extra_field = 'extra_'.$field_details[1]; |
4716 | 4716 | $form->addElement('file', $extra_field, $field_details[3], null, ''); |
4717 | 4717 | if ($extra_file_list = UserManager::build_user_extra_file_list($user_id, $field_details[1], '', true)) { |
4718 | - $form->addElement('static', $extra_field . '_list', null, $extra_file_list); |
|
4718 | + $form->addElement('static', $extra_field.'_list', null, $extra_file_list); |
|
4719 | 4719 | } |
4720 | 4720 | if ($field_details[7] == 0) { |
4721 | 4721 | $form->freeze($extra_field); |
@@ -4883,7 +4883,7 @@ discard block |
||
4883 | 4883 | $direction = null, |
4884 | 4884 | $active = null, |
4885 | 4885 | $lastConnectionDate = null |
4886 | - ){ |
|
4886 | + ) { |
|
4887 | 4887 | return self::getUsersFollowedByUser( |
4888 | 4888 | $userId, |
4889 | 4889 | $userStatus, |
@@ -5090,12 +5090,12 @@ discard block |
||
5090 | 5090 | if (!empty($_SERVER['HTTPS'])) { |
5091 | 5091 | $url = 'https://secure.gravatar.com/avatar/'; |
5092 | 5092 | } |
5093 | - $url .= md5( strtolower( trim( $email ) ) ); |
|
5093 | + $url .= md5(strtolower(trim($email))); |
|
5094 | 5094 | $url .= "?s=$s&d=$d&r=$r"; |
5095 | - if ( $img ) { |
|
5096 | - $url = '<img src="' . $url . '"'; |
|
5097 | - foreach ( $atts as $key => $val ) |
|
5098 | - $url .= ' ' . $key . '="' . $val . '"'; |
|
5095 | + if ($img) { |
|
5096 | + $url = '<img src="'.$url.'"'; |
|
5097 | + foreach ($atts as $key => $val) |
|
5098 | + $url .= ' '.$key.'="'.$val.'"'; |
|
5099 | 5099 | $url .= ' />'; |
5100 | 5100 | } |
5101 | 5101 | return $url; |
@@ -1231,13 +1231,13 @@ discard block |
||
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | /** |
1234 | - * Get the users by ID |
|
1235 | - * @param array $ids student ids |
|
1236 | - * @param string $active |
|
1237 | - * @param string $order |
|
1238 | - * @param string $limit |
|
1239 | - * @return array $result student information |
|
1240 | - */ |
|
1234 | + * Get the users by ID |
|
1235 | + * @param array $ids student ids |
|
1236 | + * @param string $active |
|
1237 | + * @param string $order |
|
1238 | + * @param string $limit |
|
1239 | + * @return array $result student information |
|
1240 | + */ |
|
1241 | 1241 | public static function get_user_list_by_ids($ids = array(), $active = null, $order = null, $limit = null) |
1242 | 1242 | { |
1243 | 1243 | if (empty($ids)) { |
@@ -2275,7 +2275,7 @@ discard block |
||
2275 | 2275 | * |
2276 | 2276 | * @return array with extra data info of a user i.e array('field_variable'=>'value'); |
2277 | 2277 | */ |
2278 | - public static function get_extra_user_data_by_value($field_variable, $field_value, $all_visibility = true) |
|
2278 | + public static function get_extra_user_data_by_value($field_variable, $field_value, $all_visibility = true) |
|
2279 | 2279 | { |
2280 | 2280 | $extraField = new ExtraFieldValue('user'); |
2281 | 2281 | |
@@ -3352,12 +3352,12 @@ discard block |
||
3352 | 3352 | if ($tag_id == 0) { |
3353 | 3353 | //the tag doesn't exist |
3354 | 3354 | $sql = "INSERT INTO $table_user_tag (tag, field_id,count) VALUES ('$tag','$field_id', count + 1)"; |
3355 | - Database::query($sql); |
|
3355 | + Database::query($sql); |
|
3356 | 3356 | $last_insert_id = Database::insert_id(); |
3357 | 3357 | } else { |
3358 | 3358 | //the tag exists we update it |
3359 | 3359 | $sql = "UPDATE $table_user_tag SET count = count + 1 WHERE id = $tag_id"; |
3360 | - Database::query($sql); |
|
3360 | + Database::query($sql); |
|
3361 | 3361 | $last_insert_id = $tag_id; |
3362 | 3362 | } |
3363 | 3363 | |
@@ -3552,9 +3552,9 @@ discard block |
||
3552 | 3552 | } |
3553 | 3553 | |
3554 | 3554 | /** |
3555 | - * Get extra filtrable user fields (only type select) |
|
3556 | - * @return array |
|
3557 | - */ |
|
3555 | + * Get extra filtrable user fields (only type select) |
|
3556 | + * @return array |
|
3557 | + */ |
|
3558 | 3558 | public static function get_extra_filtrable_fields() |
3559 | 3559 | { |
3560 | 3560 | $extraFieldList = UserManager::get_extra_fields(); |
@@ -3579,9 +3579,9 @@ discard block |
||
3579 | 3579 | } |
3580 | 3580 | |
3581 | 3581 | /** |
3582 | - * Get extra where clauses for finding users based on extra filtrable user fields (type select) |
|
3583 | - * @return string With AND clauses based on user's ID which have the values to search in extra user fields |
|
3584 | - */ |
|
3582 | + * Get extra where clauses for finding users based on extra filtrable user fields (type select) |
|
3583 | + * @return string With AND clauses based on user's ID which have the values to search in extra user fields |
|
3584 | + */ |
|
3585 | 3585 | public static function get_search_form_where_extra_fields() |
3586 | 3586 | { |
3587 | 3587 | $useExtraFields = false; |
@@ -3900,23 +3900,23 @@ discard block |
||
3900 | 3900 | } |
3901 | 3901 | |
3902 | 3902 | /** |
3903 | - * Get users followed by human resource manager |
|
3904 | - * @param int $userId |
|
3905 | - * @param int $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc) |
|
3906 | - * @param bool $getOnlyUserId |
|
3907 | - * @param bool $getSql |
|
3908 | - * @param bool $getCount |
|
3909 | - * @param int $from |
|
3910 | - * @param int $numberItems |
|
3911 | - * @param int $column |
|
3912 | - * @param string $direction |
|
3913 | - * @param int $active |
|
3914 | - * @param string $lastConnectionDate |
|
3915 | - * @param int $status the function is called by who? COURSEMANAGER, DRH? |
|
3916 | - * @param string $keyword |
|
3903 | + * Get users followed by human resource manager |
|
3904 | + * @param int $userId |
|
3905 | + * @param int $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc) |
|
3906 | + * @param bool $getOnlyUserId |
|
3907 | + * @param bool $getSql |
|
3908 | + * @param bool $getCount |
|
3909 | + * @param int $from |
|
3910 | + * @param int $numberItems |
|
3911 | + * @param int $column |
|
3912 | + * @param string $direction |
|
3913 | + * @param int $active |
|
3914 | + * @param string $lastConnectionDate |
|
3915 | + * @param int $status the function is called by who? COURSEMANAGER, DRH? |
|
3916 | + * @param string $keyword |
|
3917 | 3917 | * |
3918 | - * @return array user list |
|
3919 | - */ |
|
3918 | + * @return array user list |
|
3919 | + */ |
|
3920 | 3920 | public static function getUsersFollowedByUser( |
3921 | 3921 | $userId, |
3922 | 3922 | $userStatus = null, |
@@ -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,1145 +72,1145 @@ 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 | - |
|
527 | - $requestMode = -1; |
|
528 | - $sFunctionName = ""; |
|
529 | - $bFoundFunction = true; |
|
530 | - $bFunctionIsCatchAll = false; |
|
531 | - $sFunctionNameForSpecial = ""; |
|
532 | - $aArgs = array(); |
|
533 | - $sPreResponse = ""; |
|
534 | - $bEndRequest = false; |
|
535 | - $sResponse = ""; |
|
536 | - |
|
537 | - $requestMode = $this->getRequestMode(); |
|
538 | - if ($requestMode == -1) return; |
|
539 | - |
|
540 | - if ($requestMode == XAJAX_POST) |
|
541 | - { |
|
542 | - $sFunctionName = $_POST["xajax"]; |
|
543 | - |
|
544 | - if (!empty($_POST["xajaxargs"])) |
|
545 | - $aArgs = $_POST["xajaxargs"]; |
|
546 | - } |
|
547 | - else |
|
548 | - { |
|
549 | - header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
550 | - header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
551 | - header ("Cache-Control: no-cache, must-revalidate"); |
|
552 | - header ("Pragma: no-cache"); |
|
553 | - |
|
554 | - $sFunctionName = $_GET["xajax"]; |
|
555 | - |
|
556 | - if (!empty($_GET["xajaxargs"])) |
|
557 | - $aArgs = $_GET["xajaxargs"]; |
|
558 | - } |
|
559 | - |
|
560 | - // Use xajax error handler if necessary |
|
561 | - if ($this->bErrorHandler) { |
|
562 | - $GLOBALS['xajaxErrorHandlerText'] = ""; |
|
563 | - set_error_handler("xajaxErrorHandler"); |
|
564 | - } |
|
565 | - |
|
566 | - if ($this->sPreFunction) { |
|
567 | - if (!$this->_isFunctionCallable($this->sPreFunction)) { |
|
568 | - $bFoundFunction = false; |
|
569 | - $objResponse = new xajaxResponse(); |
|
570 | - $objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction); |
|
571 | - $sResponse = $objResponse->getXML(); |
|
572 | - } |
|
573 | - } |
|
574 | - //include any external dependencies associated with this function name |
|
575 | - if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles)) |
|
576 | - { |
|
577 | - ob_start(); |
|
578 | - include_once($this->aFunctionIncludeFiles[$sFunctionName]); |
|
579 | - ob_end_clean(); |
|
580 | - } |
|
581 | - |
|
582 | - if ($bFoundFunction) { |
|
583 | - $sFunctionNameForSpecial = $sFunctionName; |
|
584 | - if (!array_key_exists($sFunctionName, $this->aFunctions)) |
|
585 | - { |
|
586 | - if ($this->sCatchAllFunction) { |
|
587 | - $sFunctionName = $this->sCatchAllFunction; |
|
588 | - $bFunctionIsCatchAll = true; |
|
589 | - } |
|
590 | - else { |
|
591 | - $bFoundFunction = false; |
|
592 | - $objResponse = new xajaxResponse(); |
|
593 | - $objResponse->addAlert("Unknown Function $sFunctionName."); |
|
594 | - $sResponse = $objResponse->getXML(); |
|
595 | - } |
|
596 | - } |
|
597 | - else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode) |
|
598 | - { |
|
599 | - $bFoundFunction = false; |
|
600 | - $objResponse = new xajaxResponse(); |
|
601 | - $objResponse->addAlert("Incorrect Request Type."); |
|
602 | - $sResponse = $objResponse->getXML(); |
|
603 | - } |
|
604 | - } |
|
605 | - |
|
606 | - if ($bFoundFunction) |
|
607 | - { |
|
608 | - for ($i = 0; $i < sizeof($aArgs); $i++) |
|
609 | - { |
|
610 | - // If magic quotes is on, then we need to strip the slashes from the args |
|
611 | - if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) { |
|
612 | - |
|
613 | - $aArgs[$i] = stripslashes($aArgs[$i]); |
|
614 | - } |
|
615 | - if (stristr($aArgs[$i],"<xjxobj>") != false) |
|
616 | - { |
|
617 | - $aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]); |
|
618 | - } |
|
619 | - else if (stristr($aArgs[$i],"<xjxquery>") != false) |
|
620 | - { |
|
621 | - $aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]); |
|
622 | - } |
|
623 | - else if ($this->bDecodeUTF8Input) |
|
624 | - { |
|
625 | - $aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]); |
|
626 | - } |
|
627 | - } |
|
628 | - |
|
629 | - if ($this->sPreFunction) { |
|
630 | - $mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs)); |
|
631 | - if (is_array($mPreResponse) && $mPreResponse[0] === false) { |
|
632 | - $bEndRequest = true; |
|
633 | - $sPreResponse = $mPreResponse[1]; |
|
634 | - } |
|
635 | - else { |
|
636 | - $sPreResponse = $mPreResponse; |
|
637 | - } |
|
638 | - if (is_a($sPreResponse, "xajaxResponse")) { |
|
639 | - $sPreResponse = $sPreResponse->getXML(); |
|
640 | - } |
|
641 | - if ($bEndRequest) $sResponse = $sPreResponse; |
|
642 | - } |
|
643 | - |
|
644 | - if (!$bEndRequest) { |
|
645 | - if (!$this->_isFunctionCallable($sFunctionName)) { |
|
646 | - $objResponse = new xajaxResponse(); |
|
647 | - $objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found."); |
|
648 | - $sResponse = $objResponse->getXML(); |
|
649 | - } |
|
650 | - else { |
|
651 | - if ($bFunctionIsCatchAll) { |
|
652 | - $aArgs = array($sFunctionNameForSpecial, $aArgs); |
|
653 | - } |
|
654 | - $sResponse = $this->_callFunction($sFunctionName, $aArgs); |
|
655 | - } |
|
656 | - if (is_a($sResponse, "xajaxResponse")) { |
|
657 | - $sResponse = $sResponse->getXML(); |
|
658 | - } |
|
659 | - if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) { |
|
660 | - $objResponse = new xajaxResponse(); |
|
661 | - $objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName."); |
|
662 | - $sResponse = $objResponse->getXML(); |
|
663 | - } |
|
664 | - else if ($sPreResponse != "") { |
|
665 | - $sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities); |
|
666 | - $sNewResponse->loadXML($sPreResponse); |
|
667 | - $sNewResponse->loadXML($sResponse); |
|
668 | - $sResponse = $sNewResponse->getXML(); |
|
669 | - } |
|
670 | - } |
|
671 | - } |
|
672 | - |
|
673 | - $sContentHeader = "Content-type: text/xml;"; |
|
674 | - if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
|
675 | - $sContentHeader .= " charset=".$this->sEncoding; |
|
676 | - header($sContentHeader); |
|
677 | - if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) { |
|
678 | - $sErrorResponse = new xajaxResponse(); |
|
679 | - $sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']); |
|
680 | - if ($this->sLogFile) { |
|
681 | - $fH = @fopen($this->sLogFile, "a"); |
|
682 | - if (!$fH) { |
|
683 | - $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile); |
|
684 | - } |
|
685 | - else { |
|
686 | - fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n"); |
|
687 | - fclose($fH); |
|
688 | - } |
|
689 | - } |
|
690 | - |
|
691 | - $sErrorResponse->loadXML($sResponse); |
|
692 | - $sResponse = $sErrorResponse->getXML(); |
|
693 | - |
|
694 | - } |
|
695 | - if ($this->bCleanBuffer) while (@ob_end_clean()); |
|
696 | - print $sResponse; |
|
697 | - if ($this->bErrorHandler) restore_error_handler(); |
|
698 | - |
|
699 | - if ($this->bExitAllowed) |
|
700 | - exit(); |
|
701 | - } |
|
702 | - |
|
703 | - /** |
|
704 | - * Prints the xajax Javascript header and wrapper code into your page by |
|
705 | - * printing the output of the getJavascript() method. It should only be |
|
706 | - * called between the <pre><head> </head></pre> tags in your HTML page. |
|
707 | - * Remember, if you only want to obtain the result of this function, use |
|
708 | - * {@link xajax::getJavascript()} instead. |
|
709 | - * |
|
710 | - * <i>Usage:</i> |
|
711 | - * <code> |
|
712 | - * <head> |
|
713 | - * ... |
|
714 | - * < ?php $xajax->printJavascript(); ? > |
|
715 | - * </code> |
|
716 | - * |
|
717 | - * @param string the relative address of the folder where xajax has been |
|
718 | - * installed. For instance, if your PHP file is |
|
719 | - * "http://www.myserver.com/myfolder/mypage.php" |
|
720 | - * and xajax was installed in |
|
721 | - * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
722 | - * should be set to "../anotherfolder". Defaults to assuming |
|
723 | - * xajax is in the same folder as your PHP file. |
|
724 | - * @param string the relative folder/file pair of the xajax Javascript |
|
725 | - * engine located within the xajax installation folder. |
|
726 | - * Defaults to xajax_js/xajax.js. |
|
727 | - */ |
|
728 | - function printJavascript($sJsURI="", $sJsFile=NULL) |
|
729 | - { |
|
730 | - print $this->getJavascript($sJsURI, $sJsFile); |
|
731 | - } |
|
732 | - |
|
733 | - /** |
|
734 | - * Returns the xajax Javascript code that should be added to your HTML page |
|
735 | - * between the <kbd><head> </head></kbd> tags. |
|
736 | - * |
|
737 | - * <i>Usage:</i> |
|
738 | - * <code> |
|
739 | - * < ?php $xajaxJSHead = $xajax->getJavascript(); ? > |
|
740 | - * <head> |
|
741 | - * ... |
|
742 | - * < ?php echo $xajaxJSHead; ? > |
|
743 | - * </code> |
|
744 | - * |
|
745 | - * @param string the relative address of the folder where xajax has been |
|
746 | - * installed. For instance, if your PHP file is |
|
747 | - * "http://www.myserver.com/myfolder/mypage.php" |
|
748 | - * and xajax was installed in |
|
749 | - * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
750 | - * should be set to "../anotherfolder". Defaults to assuming |
|
751 | - * xajax is in the same folder as your PHP file. |
|
752 | - * @param string the relative folder/file pair of the xajax Javascript |
|
753 | - * engine located within the xajax installation folder. |
|
754 | - * Defaults to xajax_js/xajax.js. |
|
755 | - * @return string |
|
756 | - */ |
|
757 | - function getJavascript($sJsURI="", $sJsFile=NULL) |
|
758 | - { |
|
759 | - $html = $this->getJavascriptConfig(); |
|
760 | - $html .= $this->getJavascriptInclude($sJsURI, $sJsFile); |
|
761 | - |
|
762 | - return $html; |
|
763 | - } |
|
764 | - |
|
765 | - /** |
|
766 | - * Returns a string containing inline Javascript that sets up the xajax |
|
767 | - * runtime (typically called internally by xajax from get/printJavascript). |
|
768 | - * |
|
769 | - * @return string |
|
770 | - */ |
|
771 | - function getJavascriptConfig() |
|
772 | - { |
|
773 | - $html = "\t<script type=\"text/javascript\">\n"; |
|
774 | - $html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n"; |
|
775 | - $html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n"; |
|
776 | - $html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n"; |
|
777 | - $html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n"; |
|
778 | - $html .= "var xajaxDefinedGet=".XAJAX_GET.";\n"; |
|
779 | - $html .= "var xajaxDefinedPost=".XAJAX_POST.";\n"; |
|
780 | - $html .= "var xajaxLoaded=false;\n"; |
|
781 | - |
|
782 | - foreach($this->aFunctions as $sFunction => $bExists) { |
|
783 | - $html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]); |
|
784 | - } |
|
785 | - |
|
786 | - $html .= "\t</script>\n"; |
|
787 | - return $html; |
|
788 | - } |
|
789 | - |
|
790 | - /** |
|
791 | - * Returns a string containing a Javascript include of the xajax.js file |
|
792 | - * along with a check to see if the file loaded after six seconds |
|
793 | - * (typically called internally by xajax from get/printJavascript). |
|
794 | - * |
|
795 | - * @param string the relative address of the folder where xajax has been |
|
796 | - * installed. For instance, if your PHP file is |
|
797 | - * "http://www.myserver.com/myfolder/mypage.php" |
|
798 | - * and xajax was installed in |
|
799 | - * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
800 | - * should be set to "../anotherfolder". Defaults to assuming |
|
801 | - * xajax is in the same folder as your PHP file. |
|
802 | - * @param string the relative folder/file pair of the xajax Javascript |
|
803 | - * engine located within the xajax installation folder. |
|
804 | - * Defaults to xajax_js/xajax.js. |
|
805 | - * @return string |
|
806 | - */ |
|
807 | - function getJavascriptInclude($sJsURI="", $sJsFile=NULL) |
|
808 | - { |
|
809 | - if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js"; |
|
810 | - |
|
811 | - if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/"; |
|
812 | - |
|
813 | - $html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n"; |
|
814 | - $html .= "\t<script type=\"text/javascript\">\n"; |
|
815 | - $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"; |
|
816 | - $html .= "\t</script>\n"; |
|
817 | - return $html; |
|
818 | - } |
|
819 | - |
|
820 | - /** |
|
821 | - * This method can be used to create a new xajax.js file out of the |
|
822 | - * xajax_uncompressed.js file (which will only happen if xajax.js doesn't |
|
823 | - * already exist on the filesystem). |
|
824 | - * |
|
825 | - * @param string an optional argument containing the full server file path |
|
826 | - * of xajax.js. |
|
827 | - */ |
|
828 | - function autoCompressJavascript($sJsFullFilename=NULL) |
|
829 | - { |
|
830 | - $sJsFile = "xajax_js/xajax.js"; |
|
831 | - |
|
832 | - if ($sJsFullFilename) { |
|
833 | - $realJsFile = $sJsFullFilename; |
|
834 | - } |
|
835 | - else { |
|
836 | - $realPath = realpath(dirname(__FILE__)); |
|
837 | - $realJsFile = $realPath . "/". $sJsFile; |
|
838 | - } |
|
839 | - |
|
840 | - // Create a compressed file if necessary |
|
841 | - if (!file_exists($realJsFile)) { |
|
842 | - $srcFile = str_replace(".js", "_uncompressed.js", $realJsFile); |
|
843 | - if (!file_exists($srcFile)) { |
|
844 | - trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR); |
|
845 | - } |
|
846 | - require(dirname(__FILE__)."/xajaxCompress.php"); |
|
847 | - $javaScript = implode('', file($srcFile)); |
|
848 | - $compressedScript = xajaxCompressJavascript($javaScript); |
|
849 | - $fH = @fopen($realJsFile, "w"); |
|
850 | - if (!$fH) { |
|
851 | - 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 { |
|
854 | - fwrite($fH, $compressedScript); |
|
855 | - fclose($fH); |
|
856 | - } |
|
857 | - } |
|
858 | - } |
|
859 | - |
|
860 | - /** |
|
861 | - * Returns the current URL based upon the SERVER vars. |
|
862 | - * |
|
863 | - * @access private |
|
864 | - * @return string |
|
865 | - */ |
|
866 | - function _detectURI() { |
|
867 | - $aURL = array(); |
|
868 | - |
|
869 | - // Try to get the request URL |
|
870 | - if (!empty($_SERVER['REQUEST_URI'])) { |
|
871 | - $aURL = parse_url($_SERVER['REQUEST_URI']); |
|
872 | - } |
|
873 | - |
|
874 | - // Fill in the empty values |
|
875 | - if (empty($aURL['scheme'])) { |
|
876 | - if (!empty($_SERVER['HTTP_SCHEME'])) { |
|
877 | - $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
|
878 | - } else { |
|
879 | - $aURL['scheme'] = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http'; |
|
880 | - } |
|
881 | - } |
|
882 | - |
|
883 | - if (empty($aURL['host'])) { |
|
884 | - if (!empty($_SERVER['HTTP_HOST'])) { |
|
885 | - if (strpos($_SERVER['HTTP_HOST'], ':') > 0) { |
|
886 | - list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']); |
|
887 | - } else { |
|
888 | - $aURL['host'] = $_SERVER['HTTP_HOST']; |
|
889 | - } |
|
890 | - } else if (!empty($_SERVER['SERVER_NAME'])) { |
|
891 | - $aURL['host'] = $_SERVER['SERVER_NAME']; |
|
892 | - } else { |
|
893 | - print "xajax Error: xajax failed to automatically identify your Request URI."; |
|
894 | - print "Please set the Request URI explicitly when you instantiate the xajax object."; |
|
895 | - exit(); |
|
896 | - } |
|
897 | - } |
|
898 | - |
|
899 | - if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) { |
|
900 | - $aURL['port'] = $_SERVER['SERVER_PORT']; |
|
901 | - } |
|
902 | - |
|
903 | - if (empty($aURL['path'])) { |
|
904 | - if (!empty($_SERVER['PATH_INFO'])) { |
|
905 | - $sPath = parse_url($_SERVER['PATH_INFO']); |
|
906 | - } else { |
|
907 | - $sPath = parse_url(api_get_self()); |
|
908 | - } |
|
909 | - $aURL['path'] = $sPath['path']; |
|
910 | - unset($sPath); |
|
911 | - } |
|
912 | - |
|
913 | - if (!empty($aURL['query'])) { |
|
914 | - $aURL['query'] = '?'.$aURL['query']; |
|
915 | - } |
|
916 | - |
|
917 | - // Build the URL: Start with scheme, user and pass |
|
918 | - $sURL = $aURL['scheme'].'://'; |
|
919 | - if (!empty($aURL['user'])) { |
|
920 | - $sURL.= $aURL['user']; |
|
921 | - if (!empty($aURL['pass'])) { |
|
922 | - $sURL.= ':'.$aURL['pass']; |
|
923 | - } |
|
924 | - $sURL.= '@'; |
|
925 | - } |
|
926 | - |
|
927 | - // Add the host |
|
928 | - $sURL.= $aURL['host']; |
|
929 | - |
|
930 | - // Add the port if needed |
|
931 | - if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) { |
|
932 | - $sURL.= ':'.$aURL['port']; |
|
933 | - } |
|
934 | - |
|
935 | - // Add the path and the query string |
|
936 | - $sURL.= $aURL['path'].@$aURL['query']; |
|
937 | - |
|
938 | - // Clean up |
|
939 | - unset($aURL); |
|
940 | - return $sURL; |
|
941 | - } |
|
942 | - |
|
943 | - /** |
|
944 | - * Returns true if the function name is associated with an object callback, |
|
945 | - * false if not. |
|
946 | - * |
|
947 | - * @param string the name of the function |
|
948 | - * @access private |
|
949 | - * @return boolean |
|
950 | - */ |
|
951 | - function _isObjectCallback($sFunction) |
|
952 | - { |
|
953 | - if (array_key_exists($sFunction, $this->aObjects)) return true; |
|
954 | - return false; |
|
955 | - } |
|
956 | - |
|
957 | - /** |
|
958 | - * Returns true if the function or object callback can be called, false if |
|
959 | - * not. |
|
960 | - * |
|
961 | - * @param string the name of the function |
|
962 | - * @access private |
|
963 | - * @return boolean |
|
964 | - */ |
|
965 | - function _isFunctionCallable($sFunction) |
|
966 | - { |
|
967 | - if ($this->_isObjectCallback($sFunction)) { |
|
968 | - if (is_object($this->aObjects[$sFunction][0])) { |
|
969 | - return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]); |
|
970 | - } |
|
971 | - else { |
|
972 | - return is_callable($this->aObjects[$sFunction]); |
|
973 | - } |
|
974 | - } |
|
975 | - else { |
|
976 | - return function_exists($sFunction); |
|
977 | - } |
|
978 | - } |
|
979 | - |
|
980 | - /** |
|
981 | - * Calls the function, class method, or object method with the supplied |
|
982 | - * arguments. |
|
983 | - * |
|
984 | - * @param string the name of the function |
|
985 | - * @param array arguments to pass to the function |
|
986 | - * @access private |
|
987 | - * @return mixed the output of the called function or method |
|
988 | - */ |
|
989 | - function _callFunction($sFunction, $aArgs) |
|
990 | - { |
|
991 | - if ($this->_isObjectCallback($sFunction)) { |
|
992 | - $mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs); |
|
993 | - } |
|
994 | - else { |
|
995 | - $mReturn = call_user_func_array($sFunction, $aArgs); |
|
996 | - } |
|
997 | - return $mReturn; |
|
998 | - } |
|
999 | - |
|
1000 | - /** |
|
1001 | - * Generates the Javascript wrapper for the specified PHP function. |
|
1002 | - * |
|
1003 | - * @param string the name of the function |
|
1004 | - * @param mixed the request type |
|
1005 | - * @access private |
|
1006 | - * @return string |
|
1007 | - */ |
|
1008 | - function _wrap($sFunction,$sRequestType=XAJAX_POST) |
|
1009 | - { |
|
1010 | - $js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n"; |
|
1011 | - return $js; |
|
1012 | - } |
|
1013 | - |
|
1014 | - /** |
|
1015 | - * Takes a string containing xajax xjxobj XML or xjxquery XML and builds an |
|
1016 | - * array representation of it to pass as an argument to the PHP function |
|
1017 | - * being called. |
|
1018 | - * |
|
1019 | - * @param string the root tag of the XML |
|
1020 | - * @param string XML to convert |
|
1021 | - * @access private |
|
1022 | - * @return array |
|
1023 | - */ |
|
1024 | - function _xmlToArray($rootTag, $sXml) |
|
1025 | - { |
|
1026 | - $aArray = array(); |
|
1027 | - $sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml); |
|
1028 | - $sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml); |
|
1029 | - $sXml = str_replace("<e>","<e>|~|",$sXml); |
|
1030 | - $sXml = str_replace("</e>","</e>|~|",$sXml); |
|
1031 | - $sXml = str_replace("<k>","<k>|~|",$sXml); |
|
1032 | - $sXml = str_replace("</k>","|~|</k>|~|",$sXml); |
|
1033 | - $sXml = str_replace("<v>","<v>|~|",$sXml); |
|
1034 | - $sXml = str_replace("</v>","|~|</v>|~|",$sXml); |
|
1035 | - $sXml = str_replace("<q>","<q>|~|",$sXml); |
|
1036 | - $sXml = str_replace("</q>","|~|</q>|~|",$sXml); |
|
1037 | - |
|
1038 | - $this->aObjArray = explode("|~|",$sXml); |
|
1039 | - |
|
1040 | - $this->iPos = 0; |
|
1041 | - $aArray = $this->_parseObjXml($rootTag); |
|
1042 | - |
|
1043 | - return $aArray; |
|
1044 | - } |
|
1045 | - |
|
1046 | - /** |
|
1047 | - * A recursive function that generates an array from the contents of |
|
1048 | - * $this->aObjArray. |
|
1049 | - * |
|
1050 | - * @param string the root tag of the XML |
|
1051 | - * @access private |
|
1052 | - * @return array |
|
1053 | - */ |
|
1054 | - function _parseObjXml($rootTag) |
|
1055 | - { |
|
1056 | - $aArray = array(); |
|
1057 | - |
|
1058 | - if ($rootTag == "xjxobj") |
|
1059 | - { |
|
1060 | - while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>")) |
|
1061 | - { |
|
1062 | - $this->iPos++; |
|
1063 | - if(stristr($this->aObjArray[$this->iPos],"<e>")) |
|
1064 | - { |
|
1065 | - $key = ""; |
|
1066 | - $value = null; |
|
1067 | - |
|
1068 | - $this->iPos++; |
|
1069 | - while(!stristr($this->aObjArray[$this->iPos],"</e>")) |
|
1070 | - { |
|
1071 | - if(stristr($this->aObjArray[$this->iPos],"<k>")) |
|
1072 | - { |
|
1073 | - $this->iPos++; |
|
1074 | - while(!stristr($this->aObjArray[$this->iPos],"</k>")) |
|
1075 | - { |
|
1076 | - $key .= $this->aObjArray[$this->iPos]; |
|
1077 | - $this->iPos++; |
|
1078 | - } |
|
1079 | - } |
|
1080 | - if(stristr($this->aObjArray[$this->iPos],"<v>")) |
|
1081 | - { |
|
1082 | - $this->iPos++; |
|
1083 | - while(!stristr($this->aObjArray[$this->iPos],"</v>")) |
|
1084 | - { |
|
1085 | - if(stristr($this->aObjArray[$this->iPos],"<xjxobj>")) |
|
1086 | - { |
|
1087 | - $value = $this->_parseObjXml("xjxobj"); |
|
1088 | - $this->iPos++; |
|
1089 | - } |
|
1090 | - else |
|
1091 | - { |
|
1092 | - $value .= $this->aObjArray[$this->iPos]; |
|
1093 | - if ($this->bDecodeUTF8Input) |
|
1094 | - { |
|
1095 | - $value = $this->_decodeUTF8Data($value); |
|
1096 | - } |
|
1097 | - } |
|
1098 | - $this->iPos++; |
|
1099 | - } |
|
1100 | - } |
|
1101 | - $this->iPos++; |
|
1102 | - } |
|
1103 | - |
|
1104 | - $aArray[$key]=$value; |
|
1105 | - } |
|
1106 | - } |
|
1107 | - } |
|
1108 | - |
|
1109 | - if ($rootTag == "xjxquery") |
|
1110 | - { |
|
1111 | - $sQuery = ""; |
|
1112 | - $this->iPos++; |
|
1113 | - while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>")) |
|
1114 | - { |
|
1115 | - if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>")) |
|
1116 | - { |
|
1117 | - $this->iPos++; |
|
1118 | - continue; |
|
1119 | - } |
|
1120 | - $sQuery .= $this->aObjArray[$this->iPos]; |
|
1121 | - $this->iPos++; |
|
1122 | - } |
|
1123 | - |
|
1124 | - parse_str($sQuery, $aArray); |
|
1125 | - if ($this->bDecodeUTF8Input) |
|
1126 | - { |
|
1127 | - foreach($aArray as $key => $value) |
|
1128 | - { |
|
1129 | - $aArray[$key] = $this->_decodeUTF8Data($value); |
|
1130 | - } |
|
1131 | - } |
|
1132 | - // If magic quotes is on, then we need to strip the slashes from the |
|
1133 | - // array values because of the parse_str pass which adds slashes |
|
1134 | - if (get_magic_quotes_gpc() == 1) { |
|
1135 | - $newArray = array(); |
|
1136 | - foreach ($aArray as $sKey => $sValue) { |
|
1137 | - if (is_string($sValue)) |
|
1138 | - $newArray[$sKey] = stripslashes($sValue); |
|
1139 | - else |
|
1140 | - $newArray[$sKey] = $sValue; |
|
1141 | - } |
|
1142 | - $aArray = $newArray; |
|
1143 | - } |
|
1144 | - } |
|
1145 | - |
|
1146 | - return $aArray; |
|
1147 | - } |
|
1148 | - |
|
1149 | - /** |
|
1150 | - * Decodes string data from UTF-8 to the current xajax encoding. |
|
1151 | - * |
|
1152 | - * @param string data to convert |
|
1153 | - * @access private |
|
1154 | - * @return string converted data |
|
1155 | - */ |
|
1156 | - function _decodeUTF8Data($sData) |
|
1157 | - { |
|
1158 | - $sValue = $sData; |
|
1159 | - if ($this->bDecodeUTF8Input) |
|
1160 | - { |
|
1161 | - $sFuncToUse = NULL; |
|
1162 | - |
|
1163 | - // An adaptation for the Dokeos LMS, 22-AUG-2009. |
|
1164 | - if (function_exists('api_convert_encoding')) |
|
1165 | - { |
|
1166 | - $sFuncToUse = "api_convert_encoding"; |
|
1167 | - } |
|
1168 | - //if (function_exists('iconv')) |
|
1169 | - elseif (function_exists('iconv')) |
|
1170 | - // |
|
1171 | - { |
|
1172 | - $sFuncToUse = "iconv"; |
|
1173 | - } |
|
1174 | - else if (function_exists('mb_convert_encoding')) |
|
1175 | - { |
|
1176 | - $sFuncToUse = "mb_convert_encoding"; |
|
1177 | - } |
|
1178 | - else if ($this->sEncoding == "ISO-8859-1") |
|
1179 | - { |
|
1180 | - $sFuncToUse = "utf8_decode"; |
|
1181 | - } |
|
1182 | - else |
|
1183 | - { |
|
1184 | - trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE); |
|
1185 | - } |
|
1186 | - |
|
1187 | - if ($sFuncToUse) |
|
1188 | - { |
|
1189 | - if (is_string($sValue)) |
|
1190 | - { |
|
1191 | - if ($sFuncToUse == "iconv") |
|
1192 | - { |
|
1193 | - $sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue); |
|
1194 | - } |
|
1195 | - else if ($sFuncToUse == "mb_convert_encoding") |
|
1196 | - { |
|
1197 | - $sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8"); |
|
1198 | - } |
|
1199 | - // Added code, an adaptation for the Dokeos LMS, 22-AUG-2009. |
|
1200 | - else if ($sFuncToUse == "api_convert_encoding") |
|
1201 | - { |
|
1202 | - $sValue = api_convert_encoding($sValue, $this->sEncoding, "UTF-8"); |
|
1203 | - } |
|
1204 | - // |
|
1205 | - else |
|
1206 | - { |
|
1207 | - $sValue = utf8_decode($sValue); |
|
1208 | - } |
|
1209 | - } |
|
1210 | - } |
|
1211 | - } |
|
1212 | - return $sValue; |
|
1213 | - } |
|
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 | + |
|
527 | + $requestMode = -1; |
|
528 | + $sFunctionName = ""; |
|
529 | + $bFoundFunction = true; |
|
530 | + $bFunctionIsCatchAll = false; |
|
531 | + $sFunctionNameForSpecial = ""; |
|
532 | + $aArgs = array(); |
|
533 | + $sPreResponse = ""; |
|
534 | + $bEndRequest = false; |
|
535 | + $sResponse = ""; |
|
536 | + |
|
537 | + $requestMode = $this->getRequestMode(); |
|
538 | + if ($requestMode == -1) return; |
|
539 | + |
|
540 | + if ($requestMode == XAJAX_POST) |
|
541 | + { |
|
542 | + $sFunctionName = $_POST["xajax"]; |
|
543 | + |
|
544 | + if (!empty($_POST["xajaxargs"])) |
|
545 | + $aArgs = $_POST["xajaxargs"]; |
|
546 | + } |
|
547 | + else |
|
548 | + { |
|
549 | + header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
550 | + header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
551 | + header ("Cache-Control: no-cache, must-revalidate"); |
|
552 | + header ("Pragma: no-cache"); |
|
553 | + |
|
554 | + $sFunctionName = $_GET["xajax"]; |
|
555 | + |
|
556 | + if (!empty($_GET["xajaxargs"])) |
|
557 | + $aArgs = $_GET["xajaxargs"]; |
|
558 | + } |
|
559 | + |
|
560 | + // Use xajax error handler if necessary |
|
561 | + if ($this->bErrorHandler) { |
|
562 | + $GLOBALS['xajaxErrorHandlerText'] = ""; |
|
563 | + set_error_handler("xajaxErrorHandler"); |
|
564 | + } |
|
565 | + |
|
566 | + if ($this->sPreFunction) { |
|
567 | + if (!$this->_isFunctionCallable($this->sPreFunction)) { |
|
568 | + $bFoundFunction = false; |
|
569 | + $objResponse = new xajaxResponse(); |
|
570 | + $objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction); |
|
571 | + $sResponse = $objResponse->getXML(); |
|
572 | + } |
|
573 | + } |
|
574 | + //include any external dependencies associated with this function name |
|
575 | + if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles)) |
|
576 | + { |
|
577 | + ob_start(); |
|
578 | + include_once($this->aFunctionIncludeFiles[$sFunctionName]); |
|
579 | + ob_end_clean(); |
|
580 | + } |
|
581 | + |
|
582 | + if ($bFoundFunction) { |
|
583 | + $sFunctionNameForSpecial = $sFunctionName; |
|
584 | + if (!array_key_exists($sFunctionName, $this->aFunctions)) |
|
585 | + { |
|
586 | + if ($this->sCatchAllFunction) { |
|
587 | + $sFunctionName = $this->sCatchAllFunction; |
|
588 | + $bFunctionIsCatchAll = true; |
|
589 | + } |
|
590 | + else { |
|
591 | + $bFoundFunction = false; |
|
592 | + $objResponse = new xajaxResponse(); |
|
593 | + $objResponse->addAlert("Unknown Function $sFunctionName."); |
|
594 | + $sResponse = $objResponse->getXML(); |
|
595 | + } |
|
596 | + } |
|
597 | + else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode) |
|
598 | + { |
|
599 | + $bFoundFunction = false; |
|
600 | + $objResponse = new xajaxResponse(); |
|
601 | + $objResponse->addAlert("Incorrect Request Type."); |
|
602 | + $sResponse = $objResponse->getXML(); |
|
603 | + } |
|
604 | + } |
|
605 | + |
|
606 | + if ($bFoundFunction) |
|
607 | + { |
|
608 | + for ($i = 0; $i < sizeof($aArgs); $i++) |
|
609 | + { |
|
610 | + // If magic quotes is on, then we need to strip the slashes from the args |
|
611 | + if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) { |
|
612 | + |
|
613 | + $aArgs[$i] = stripslashes($aArgs[$i]); |
|
614 | + } |
|
615 | + if (stristr($aArgs[$i],"<xjxobj>") != false) |
|
616 | + { |
|
617 | + $aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]); |
|
618 | + } |
|
619 | + else if (stristr($aArgs[$i],"<xjxquery>") != false) |
|
620 | + { |
|
621 | + $aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]); |
|
622 | + } |
|
623 | + else if ($this->bDecodeUTF8Input) |
|
624 | + { |
|
625 | + $aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]); |
|
626 | + } |
|
627 | + } |
|
628 | + |
|
629 | + if ($this->sPreFunction) { |
|
630 | + $mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs)); |
|
631 | + if (is_array($mPreResponse) && $mPreResponse[0] === false) { |
|
632 | + $bEndRequest = true; |
|
633 | + $sPreResponse = $mPreResponse[1]; |
|
634 | + } |
|
635 | + else { |
|
636 | + $sPreResponse = $mPreResponse; |
|
637 | + } |
|
638 | + if (is_a($sPreResponse, "xajaxResponse")) { |
|
639 | + $sPreResponse = $sPreResponse->getXML(); |
|
640 | + } |
|
641 | + if ($bEndRequest) $sResponse = $sPreResponse; |
|
642 | + } |
|
643 | + |
|
644 | + if (!$bEndRequest) { |
|
645 | + if (!$this->_isFunctionCallable($sFunctionName)) { |
|
646 | + $objResponse = new xajaxResponse(); |
|
647 | + $objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found."); |
|
648 | + $sResponse = $objResponse->getXML(); |
|
649 | + } |
|
650 | + else { |
|
651 | + if ($bFunctionIsCatchAll) { |
|
652 | + $aArgs = array($sFunctionNameForSpecial, $aArgs); |
|
653 | + } |
|
654 | + $sResponse = $this->_callFunction($sFunctionName, $aArgs); |
|
655 | + } |
|
656 | + if (is_a($sResponse, "xajaxResponse")) { |
|
657 | + $sResponse = $sResponse->getXML(); |
|
658 | + } |
|
659 | + if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) { |
|
660 | + $objResponse = new xajaxResponse(); |
|
661 | + $objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName."); |
|
662 | + $sResponse = $objResponse->getXML(); |
|
663 | + } |
|
664 | + else if ($sPreResponse != "") { |
|
665 | + $sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities); |
|
666 | + $sNewResponse->loadXML($sPreResponse); |
|
667 | + $sNewResponse->loadXML($sResponse); |
|
668 | + $sResponse = $sNewResponse->getXML(); |
|
669 | + } |
|
670 | + } |
|
671 | + } |
|
672 | + |
|
673 | + $sContentHeader = "Content-type: text/xml;"; |
|
674 | + if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
|
675 | + $sContentHeader .= " charset=".$this->sEncoding; |
|
676 | + header($sContentHeader); |
|
677 | + if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) { |
|
678 | + $sErrorResponse = new xajaxResponse(); |
|
679 | + $sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']); |
|
680 | + if ($this->sLogFile) { |
|
681 | + $fH = @fopen($this->sLogFile, "a"); |
|
682 | + if (!$fH) { |
|
683 | + $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile); |
|
684 | + } |
|
685 | + else { |
|
686 | + fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n"); |
|
687 | + fclose($fH); |
|
688 | + } |
|
689 | + } |
|
690 | + |
|
691 | + $sErrorResponse->loadXML($sResponse); |
|
692 | + $sResponse = $sErrorResponse->getXML(); |
|
693 | + |
|
694 | + } |
|
695 | + if ($this->bCleanBuffer) while (@ob_end_clean()); |
|
696 | + print $sResponse; |
|
697 | + if ($this->bErrorHandler) restore_error_handler(); |
|
698 | + |
|
699 | + if ($this->bExitAllowed) |
|
700 | + exit(); |
|
701 | + } |
|
702 | + |
|
703 | + /** |
|
704 | + * Prints the xajax Javascript header and wrapper code into your page by |
|
705 | + * printing the output of the getJavascript() method. It should only be |
|
706 | + * called between the <pre><head> </head></pre> tags in your HTML page. |
|
707 | + * Remember, if you only want to obtain the result of this function, use |
|
708 | + * {@link xajax::getJavascript()} instead. |
|
709 | + * |
|
710 | + * <i>Usage:</i> |
|
711 | + * <code> |
|
712 | + * <head> |
|
713 | + * ... |
|
714 | + * < ?php $xajax->printJavascript(); ? > |
|
715 | + * </code> |
|
716 | + * |
|
717 | + * @param string the relative address of the folder where xajax has been |
|
718 | + * installed. For instance, if your PHP file is |
|
719 | + * "http://www.myserver.com/myfolder/mypage.php" |
|
720 | + * and xajax was installed in |
|
721 | + * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
722 | + * should be set to "../anotherfolder". Defaults to assuming |
|
723 | + * xajax is in the same folder as your PHP file. |
|
724 | + * @param string the relative folder/file pair of the xajax Javascript |
|
725 | + * engine located within the xajax installation folder. |
|
726 | + * Defaults to xajax_js/xajax.js. |
|
727 | + */ |
|
728 | + function printJavascript($sJsURI="", $sJsFile=NULL) |
|
729 | + { |
|
730 | + print $this->getJavascript($sJsURI, $sJsFile); |
|
731 | + } |
|
732 | + |
|
733 | + /** |
|
734 | + * Returns the xajax Javascript code that should be added to your HTML page |
|
735 | + * between the <kbd><head> </head></kbd> tags. |
|
736 | + * |
|
737 | + * <i>Usage:</i> |
|
738 | + * <code> |
|
739 | + * < ?php $xajaxJSHead = $xajax->getJavascript(); ? > |
|
740 | + * <head> |
|
741 | + * ... |
|
742 | + * < ?php echo $xajaxJSHead; ? > |
|
743 | + * </code> |
|
744 | + * |
|
745 | + * @param string the relative address of the folder where xajax has been |
|
746 | + * installed. For instance, if your PHP file is |
|
747 | + * "http://www.myserver.com/myfolder/mypage.php" |
|
748 | + * and xajax was installed in |
|
749 | + * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
750 | + * should be set to "../anotherfolder". Defaults to assuming |
|
751 | + * xajax is in the same folder as your PHP file. |
|
752 | + * @param string the relative folder/file pair of the xajax Javascript |
|
753 | + * engine located within the xajax installation folder. |
|
754 | + * Defaults to xajax_js/xajax.js. |
|
755 | + * @return string |
|
756 | + */ |
|
757 | + function getJavascript($sJsURI="", $sJsFile=NULL) |
|
758 | + { |
|
759 | + $html = $this->getJavascriptConfig(); |
|
760 | + $html .= $this->getJavascriptInclude($sJsURI, $sJsFile); |
|
761 | + |
|
762 | + return $html; |
|
763 | + } |
|
764 | + |
|
765 | + /** |
|
766 | + * Returns a string containing inline Javascript that sets up the xajax |
|
767 | + * runtime (typically called internally by xajax from get/printJavascript). |
|
768 | + * |
|
769 | + * @return string |
|
770 | + */ |
|
771 | + function getJavascriptConfig() |
|
772 | + { |
|
773 | + $html = "\t<script type=\"text/javascript\">\n"; |
|
774 | + $html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n"; |
|
775 | + $html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n"; |
|
776 | + $html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n"; |
|
777 | + $html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n"; |
|
778 | + $html .= "var xajaxDefinedGet=".XAJAX_GET.";\n"; |
|
779 | + $html .= "var xajaxDefinedPost=".XAJAX_POST.";\n"; |
|
780 | + $html .= "var xajaxLoaded=false;\n"; |
|
781 | + |
|
782 | + foreach($this->aFunctions as $sFunction => $bExists) { |
|
783 | + $html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]); |
|
784 | + } |
|
785 | + |
|
786 | + $html .= "\t</script>\n"; |
|
787 | + return $html; |
|
788 | + } |
|
789 | + |
|
790 | + /** |
|
791 | + * Returns a string containing a Javascript include of the xajax.js file |
|
792 | + * along with a check to see if the file loaded after six seconds |
|
793 | + * (typically called internally by xajax from get/printJavascript). |
|
794 | + * |
|
795 | + * @param string the relative address of the folder where xajax has been |
|
796 | + * installed. For instance, if your PHP file is |
|
797 | + * "http://www.myserver.com/myfolder/mypage.php" |
|
798 | + * and xajax was installed in |
|
799 | + * "http://www.myserver.com/anotherfolder", then $sJsURI |
|
800 | + * should be set to "../anotherfolder". Defaults to assuming |
|
801 | + * xajax is in the same folder as your PHP file. |
|
802 | + * @param string the relative folder/file pair of the xajax Javascript |
|
803 | + * engine located within the xajax installation folder. |
|
804 | + * Defaults to xajax_js/xajax.js. |
|
805 | + * @return string |
|
806 | + */ |
|
807 | + function getJavascriptInclude($sJsURI="", $sJsFile=NULL) |
|
808 | + { |
|
809 | + if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js"; |
|
810 | + |
|
811 | + if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/"; |
|
812 | + |
|
813 | + $html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n"; |
|
814 | + $html .= "\t<script type=\"text/javascript\">\n"; |
|
815 | + $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"; |
|
816 | + $html .= "\t</script>\n"; |
|
817 | + return $html; |
|
818 | + } |
|
819 | + |
|
820 | + /** |
|
821 | + * This method can be used to create a new xajax.js file out of the |
|
822 | + * xajax_uncompressed.js file (which will only happen if xajax.js doesn't |
|
823 | + * already exist on the filesystem). |
|
824 | + * |
|
825 | + * @param string an optional argument containing the full server file path |
|
826 | + * of xajax.js. |
|
827 | + */ |
|
828 | + function autoCompressJavascript($sJsFullFilename=NULL) |
|
829 | + { |
|
830 | + $sJsFile = "xajax_js/xajax.js"; |
|
831 | + |
|
832 | + if ($sJsFullFilename) { |
|
833 | + $realJsFile = $sJsFullFilename; |
|
834 | + } |
|
835 | + else { |
|
836 | + $realPath = realpath(dirname(__FILE__)); |
|
837 | + $realJsFile = $realPath . "/". $sJsFile; |
|
838 | + } |
|
839 | + |
|
840 | + // Create a compressed file if necessary |
|
841 | + if (!file_exists($realJsFile)) { |
|
842 | + $srcFile = str_replace(".js", "_uncompressed.js", $realJsFile); |
|
843 | + if (!file_exists($srcFile)) { |
|
844 | + trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR); |
|
845 | + } |
|
846 | + require(dirname(__FILE__)."/xajaxCompress.php"); |
|
847 | + $javaScript = implode('', file($srcFile)); |
|
848 | + $compressedScript = xajaxCompressJavascript($javaScript); |
|
849 | + $fH = @fopen($realJsFile, "w"); |
|
850 | + if (!$fH) { |
|
851 | + 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 { |
|
854 | + fwrite($fH, $compressedScript); |
|
855 | + fclose($fH); |
|
856 | + } |
|
857 | + } |
|
858 | + } |
|
859 | + |
|
860 | + /** |
|
861 | + * Returns the current URL based upon the SERVER vars. |
|
862 | + * |
|
863 | + * @access private |
|
864 | + * @return string |
|
865 | + */ |
|
866 | + function _detectURI() { |
|
867 | + $aURL = array(); |
|
868 | + |
|
869 | + // Try to get the request URL |
|
870 | + if (!empty($_SERVER['REQUEST_URI'])) { |
|
871 | + $aURL = parse_url($_SERVER['REQUEST_URI']); |
|
872 | + } |
|
873 | + |
|
874 | + // Fill in the empty values |
|
875 | + if (empty($aURL['scheme'])) { |
|
876 | + if (!empty($_SERVER['HTTP_SCHEME'])) { |
|
877 | + $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
|
878 | + } else { |
|
879 | + $aURL['scheme'] = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http'; |
|
880 | + } |
|
881 | + } |
|
882 | + |
|
883 | + if (empty($aURL['host'])) { |
|
884 | + if (!empty($_SERVER['HTTP_HOST'])) { |
|
885 | + if (strpos($_SERVER['HTTP_HOST'], ':') > 0) { |
|
886 | + list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']); |
|
887 | + } else { |
|
888 | + $aURL['host'] = $_SERVER['HTTP_HOST']; |
|
889 | + } |
|
890 | + } else if (!empty($_SERVER['SERVER_NAME'])) { |
|
891 | + $aURL['host'] = $_SERVER['SERVER_NAME']; |
|
892 | + } else { |
|
893 | + print "xajax Error: xajax failed to automatically identify your Request URI."; |
|
894 | + print "Please set the Request URI explicitly when you instantiate the xajax object."; |
|
895 | + exit(); |
|
896 | + } |
|
897 | + } |
|
898 | + |
|
899 | + if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) { |
|
900 | + $aURL['port'] = $_SERVER['SERVER_PORT']; |
|
901 | + } |
|
902 | + |
|
903 | + if (empty($aURL['path'])) { |
|
904 | + if (!empty($_SERVER['PATH_INFO'])) { |
|
905 | + $sPath = parse_url($_SERVER['PATH_INFO']); |
|
906 | + } else { |
|
907 | + $sPath = parse_url(api_get_self()); |
|
908 | + } |
|
909 | + $aURL['path'] = $sPath['path']; |
|
910 | + unset($sPath); |
|
911 | + } |
|
912 | + |
|
913 | + if (!empty($aURL['query'])) { |
|
914 | + $aURL['query'] = '?'.$aURL['query']; |
|
915 | + } |
|
916 | + |
|
917 | + // Build the URL: Start with scheme, user and pass |
|
918 | + $sURL = $aURL['scheme'].'://'; |
|
919 | + if (!empty($aURL['user'])) { |
|
920 | + $sURL.= $aURL['user']; |
|
921 | + if (!empty($aURL['pass'])) { |
|
922 | + $sURL.= ':'.$aURL['pass']; |
|
923 | + } |
|
924 | + $sURL.= '@'; |
|
925 | + } |
|
926 | + |
|
927 | + // Add the host |
|
928 | + $sURL.= $aURL['host']; |
|
929 | + |
|
930 | + // Add the port if needed |
|
931 | + if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) { |
|
932 | + $sURL.= ':'.$aURL['port']; |
|
933 | + } |
|
934 | + |
|
935 | + // Add the path and the query string |
|
936 | + $sURL.= $aURL['path'].@$aURL['query']; |
|
937 | + |
|
938 | + // Clean up |
|
939 | + unset($aURL); |
|
940 | + return $sURL; |
|
941 | + } |
|
942 | + |
|
943 | + /** |
|
944 | + * Returns true if the function name is associated with an object callback, |
|
945 | + * false if not. |
|
946 | + * |
|
947 | + * @param string the name of the function |
|
948 | + * @access private |
|
949 | + * @return boolean |
|
950 | + */ |
|
951 | + function _isObjectCallback($sFunction) |
|
952 | + { |
|
953 | + if (array_key_exists($sFunction, $this->aObjects)) return true; |
|
954 | + return false; |
|
955 | + } |
|
956 | + |
|
957 | + /** |
|
958 | + * Returns true if the function or object callback can be called, false if |
|
959 | + * not. |
|
960 | + * |
|
961 | + * @param string the name of the function |
|
962 | + * @access private |
|
963 | + * @return boolean |
|
964 | + */ |
|
965 | + function _isFunctionCallable($sFunction) |
|
966 | + { |
|
967 | + if ($this->_isObjectCallback($sFunction)) { |
|
968 | + if (is_object($this->aObjects[$sFunction][0])) { |
|
969 | + return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]); |
|
970 | + } |
|
971 | + else { |
|
972 | + return is_callable($this->aObjects[$sFunction]); |
|
973 | + } |
|
974 | + } |
|
975 | + else { |
|
976 | + return function_exists($sFunction); |
|
977 | + } |
|
978 | + } |
|
979 | + |
|
980 | + /** |
|
981 | + * Calls the function, class method, or object method with the supplied |
|
982 | + * arguments. |
|
983 | + * |
|
984 | + * @param string the name of the function |
|
985 | + * @param array arguments to pass to the function |
|
986 | + * @access private |
|
987 | + * @return mixed the output of the called function or method |
|
988 | + */ |
|
989 | + function _callFunction($sFunction, $aArgs) |
|
990 | + { |
|
991 | + if ($this->_isObjectCallback($sFunction)) { |
|
992 | + $mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs); |
|
993 | + } |
|
994 | + else { |
|
995 | + $mReturn = call_user_func_array($sFunction, $aArgs); |
|
996 | + } |
|
997 | + return $mReturn; |
|
998 | + } |
|
999 | + |
|
1000 | + /** |
|
1001 | + * Generates the Javascript wrapper for the specified PHP function. |
|
1002 | + * |
|
1003 | + * @param string the name of the function |
|
1004 | + * @param mixed the request type |
|
1005 | + * @access private |
|
1006 | + * @return string |
|
1007 | + */ |
|
1008 | + function _wrap($sFunction,$sRequestType=XAJAX_POST) |
|
1009 | + { |
|
1010 | + $js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n"; |
|
1011 | + return $js; |
|
1012 | + } |
|
1013 | + |
|
1014 | + /** |
|
1015 | + * Takes a string containing xajax xjxobj XML or xjxquery XML and builds an |
|
1016 | + * array representation of it to pass as an argument to the PHP function |
|
1017 | + * being called. |
|
1018 | + * |
|
1019 | + * @param string the root tag of the XML |
|
1020 | + * @param string XML to convert |
|
1021 | + * @access private |
|
1022 | + * @return array |
|
1023 | + */ |
|
1024 | + function _xmlToArray($rootTag, $sXml) |
|
1025 | + { |
|
1026 | + $aArray = array(); |
|
1027 | + $sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml); |
|
1028 | + $sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml); |
|
1029 | + $sXml = str_replace("<e>","<e>|~|",$sXml); |
|
1030 | + $sXml = str_replace("</e>","</e>|~|",$sXml); |
|
1031 | + $sXml = str_replace("<k>","<k>|~|",$sXml); |
|
1032 | + $sXml = str_replace("</k>","|~|</k>|~|",$sXml); |
|
1033 | + $sXml = str_replace("<v>","<v>|~|",$sXml); |
|
1034 | + $sXml = str_replace("</v>","|~|</v>|~|",$sXml); |
|
1035 | + $sXml = str_replace("<q>","<q>|~|",$sXml); |
|
1036 | + $sXml = str_replace("</q>","|~|</q>|~|",$sXml); |
|
1037 | + |
|
1038 | + $this->aObjArray = explode("|~|",$sXml); |
|
1039 | + |
|
1040 | + $this->iPos = 0; |
|
1041 | + $aArray = $this->_parseObjXml($rootTag); |
|
1042 | + |
|
1043 | + return $aArray; |
|
1044 | + } |
|
1045 | + |
|
1046 | + /** |
|
1047 | + * A recursive function that generates an array from the contents of |
|
1048 | + * $this->aObjArray. |
|
1049 | + * |
|
1050 | + * @param string the root tag of the XML |
|
1051 | + * @access private |
|
1052 | + * @return array |
|
1053 | + */ |
|
1054 | + function _parseObjXml($rootTag) |
|
1055 | + { |
|
1056 | + $aArray = array(); |
|
1057 | + |
|
1058 | + if ($rootTag == "xjxobj") |
|
1059 | + { |
|
1060 | + while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>")) |
|
1061 | + { |
|
1062 | + $this->iPos++; |
|
1063 | + if(stristr($this->aObjArray[$this->iPos],"<e>")) |
|
1064 | + { |
|
1065 | + $key = ""; |
|
1066 | + $value = null; |
|
1067 | + |
|
1068 | + $this->iPos++; |
|
1069 | + while(!stristr($this->aObjArray[$this->iPos],"</e>")) |
|
1070 | + { |
|
1071 | + if(stristr($this->aObjArray[$this->iPos],"<k>")) |
|
1072 | + { |
|
1073 | + $this->iPos++; |
|
1074 | + while(!stristr($this->aObjArray[$this->iPos],"</k>")) |
|
1075 | + { |
|
1076 | + $key .= $this->aObjArray[$this->iPos]; |
|
1077 | + $this->iPos++; |
|
1078 | + } |
|
1079 | + } |
|
1080 | + if(stristr($this->aObjArray[$this->iPos],"<v>")) |
|
1081 | + { |
|
1082 | + $this->iPos++; |
|
1083 | + while(!stristr($this->aObjArray[$this->iPos],"</v>")) |
|
1084 | + { |
|
1085 | + if(stristr($this->aObjArray[$this->iPos],"<xjxobj>")) |
|
1086 | + { |
|
1087 | + $value = $this->_parseObjXml("xjxobj"); |
|
1088 | + $this->iPos++; |
|
1089 | + } |
|
1090 | + else |
|
1091 | + { |
|
1092 | + $value .= $this->aObjArray[$this->iPos]; |
|
1093 | + if ($this->bDecodeUTF8Input) |
|
1094 | + { |
|
1095 | + $value = $this->_decodeUTF8Data($value); |
|
1096 | + } |
|
1097 | + } |
|
1098 | + $this->iPos++; |
|
1099 | + } |
|
1100 | + } |
|
1101 | + $this->iPos++; |
|
1102 | + } |
|
1103 | + |
|
1104 | + $aArray[$key]=$value; |
|
1105 | + } |
|
1106 | + } |
|
1107 | + } |
|
1108 | + |
|
1109 | + if ($rootTag == "xjxquery") |
|
1110 | + { |
|
1111 | + $sQuery = ""; |
|
1112 | + $this->iPos++; |
|
1113 | + while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>")) |
|
1114 | + { |
|
1115 | + if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>")) |
|
1116 | + { |
|
1117 | + $this->iPos++; |
|
1118 | + continue; |
|
1119 | + } |
|
1120 | + $sQuery .= $this->aObjArray[$this->iPos]; |
|
1121 | + $this->iPos++; |
|
1122 | + } |
|
1123 | + |
|
1124 | + parse_str($sQuery, $aArray); |
|
1125 | + if ($this->bDecodeUTF8Input) |
|
1126 | + { |
|
1127 | + foreach($aArray as $key => $value) |
|
1128 | + { |
|
1129 | + $aArray[$key] = $this->_decodeUTF8Data($value); |
|
1130 | + } |
|
1131 | + } |
|
1132 | + // If magic quotes is on, then we need to strip the slashes from the |
|
1133 | + // array values because of the parse_str pass which adds slashes |
|
1134 | + if (get_magic_quotes_gpc() == 1) { |
|
1135 | + $newArray = array(); |
|
1136 | + foreach ($aArray as $sKey => $sValue) { |
|
1137 | + if (is_string($sValue)) |
|
1138 | + $newArray[$sKey] = stripslashes($sValue); |
|
1139 | + else |
|
1140 | + $newArray[$sKey] = $sValue; |
|
1141 | + } |
|
1142 | + $aArray = $newArray; |
|
1143 | + } |
|
1144 | + } |
|
1145 | + |
|
1146 | + return $aArray; |
|
1147 | + } |
|
1148 | + |
|
1149 | + /** |
|
1150 | + * Decodes string data from UTF-8 to the current xajax encoding. |
|
1151 | + * |
|
1152 | + * @param string data to convert |
|
1153 | + * @access private |
|
1154 | + * @return string converted data |
|
1155 | + */ |
|
1156 | + function _decodeUTF8Data($sData) |
|
1157 | + { |
|
1158 | + $sValue = $sData; |
|
1159 | + if ($this->bDecodeUTF8Input) |
|
1160 | + { |
|
1161 | + $sFuncToUse = NULL; |
|
1162 | + |
|
1163 | + // An adaptation for the Dokeos LMS, 22-AUG-2009. |
|
1164 | + if (function_exists('api_convert_encoding')) |
|
1165 | + { |
|
1166 | + $sFuncToUse = "api_convert_encoding"; |
|
1167 | + } |
|
1168 | + //if (function_exists('iconv')) |
|
1169 | + elseif (function_exists('iconv')) |
|
1170 | + // |
|
1171 | + { |
|
1172 | + $sFuncToUse = "iconv"; |
|
1173 | + } |
|
1174 | + else if (function_exists('mb_convert_encoding')) |
|
1175 | + { |
|
1176 | + $sFuncToUse = "mb_convert_encoding"; |
|
1177 | + } |
|
1178 | + else if ($this->sEncoding == "ISO-8859-1") |
|
1179 | + { |
|
1180 | + $sFuncToUse = "utf8_decode"; |
|
1181 | + } |
|
1182 | + else |
|
1183 | + { |
|
1184 | + trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE); |
|
1185 | + } |
|
1186 | + |
|
1187 | + if ($sFuncToUse) |
|
1188 | + { |
|
1189 | + if (is_string($sValue)) |
|
1190 | + { |
|
1191 | + if ($sFuncToUse == "iconv") |
|
1192 | + { |
|
1193 | + $sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue); |
|
1194 | + } |
|
1195 | + else if ($sFuncToUse == "mb_convert_encoding") |
|
1196 | + { |
|
1197 | + $sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8"); |
|
1198 | + } |
|
1199 | + // Added code, an adaptation for the Dokeos LMS, 22-AUG-2009. |
|
1200 | + else if ($sFuncToUse == "api_convert_encoding") |
|
1201 | + { |
|
1202 | + $sValue = api_convert_encoding($sValue, $this->sEncoding, "UTF-8"); |
|
1203 | + } |
|
1204 | + // |
|
1205 | + else |
|
1206 | + { |
|
1207 | + $sValue = utf8_decode($sValue); |
|
1208 | + } |
|
1209 | + } |
|
1210 | + } |
|
1211 | + } |
|
1212 | + return $sValue; |
|
1213 | + } |
|
1214 | 1214 | |
1215 | 1215 | }// end class xajax |
1216 | 1216 | |
@@ -1220,31 +1220,31 @@ discard block |
||
1220 | 1220 | */ |
1221 | 1221 | function xajaxErrorHandler($errno, $errstr, $errfile, $errline) |
1222 | 1222 | { |
1223 | - $errorReporting = error_reporting(); |
|
1224 | - if (($errno & $errorReporting) == 0) return; |
|
1225 | - |
|
1226 | - if ($errno == E_NOTICE) { |
|
1227 | - $errTypeStr = "NOTICE"; |
|
1228 | - } |
|
1229 | - else if ($errno == E_WARNING) { |
|
1230 | - $errTypeStr = "WARNING"; |
|
1231 | - } |
|
1232 | - else if ($errno == E_USER_NOTICE) { |
|
1233 | - $errTypeStr = "USER NOTICE"; |
|
1234 | - } |
|
1235 | - else if ($errno == E_USER_WARNING) { |
|
1236 | - $errTypeStr = "USER WARNING"; |
|
1237 | - } |
|
1238 | - else if ($errno == E_USER_ERROR) { |
|
1239 | - $errTypeStr = "USER FATAL ERROR"; |
|
1240 | - } |
|
1241 | - else if ($errno == E_STRICT) { |
|
1242 | - return; |
|
1243 | - } |
|
1244 | - else { |
|
1245 | - $errTypeStr = "UNKNOWN: $errno"; |
|
1246 | - } |
|
1247 | - $GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile"; |
|
1223 | + $errorReporting = error_reporting(); |
|
1224 | + if (($errno & $errorReporting) == 0) return; |
|
1225 | + |
|
1226 | + if ($errno == E_NOTICE) { |
|
1227 | + $errTypeStr = "NOTICE"; |
|
1228 | + } |
|
1229 | + else if ($errno == E_WARNING) { |
|
1230 | + $errTypeStr = "WARNING"; |
|
1231 | + } |
|
1232 | + else if ($errno == E_USER_NOTICE) { |
|
1233 | + $errTypeStr = "USER NOTICE"; |
|
1234 | + } |
|
1235 | + else if ($errno == E_USER_WARNING) { |
|
1236 | + $errTypeStr = "USER WARNING"; |
|
1237 | + } |
|
1238 | + else if ($errno == E_USER_ERROR) { |
|
1239 | + $errTypeStr = "USER FATAL ERROR"; |
|
1240 | + } |
|
1241 | + else if ($errno == E_STRICT) { |
|
1242 | + return; |
|
1243 | + } |
|
1244 | + else { |
|
1245 | + $errTypeStr = "UNKNOWN: $errno"; |
|
1246 | + } |
|
1247 | + $GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile"; |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | ?> |
@@ -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 | } |
@@ -97,6 +97,7 @@ discard block |
||
97 | 97 | * @param string contains the character encoding string to use |
98 | 98 | * @param boolean lets you set if you want special characters in the output |
99 | 99 | * converted to HTML entities |
100 | + * @param string $sEncoding |
|
100 | 101 | * |
101 | 102 | */ |
102 | 103 | function xajaxResponse($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false) |
@@ -223,6 +224,8 @@ discard block |
||
223 | 224 | * @param string contains the id of an HTML element |
224 | 225 | * @param string the part of the element you wish to clear ("innerHTML", |
225 | 226 | * "value", etc.) |
227 | + * @param string $sTarget |
|
228 | + * @param string $sAttribute |
|
226 | 229 | */ |
227 | 230 | function addClear($sTarget,$sAttribute) |
228 | 231 | { |
@@ -279,6 +282,7 @@ discard block |
||
279 | 282 | * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd> |
280 | 283 | * |
281 | 284 | * @param string contains Javascript code to be executed |
285 | + * @param string $sJS |
|
282 | 286 | */ |
283 | 287 | function addScript($sJS) |
284 | 288 | { |
@@ -290,8 +294,6 @@ discard block |
||
290 | 294 | * |
291 | 295 | * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd> |
292 | 296 | * |
293 | - * @param string $sFunc the name of a Javascript function |
|
294 | - * @param mixed $args,... optional arguments to pass to the Javascript function |
|
295 | 297 | */ |
296 | 298 | function addScriptCall() { |
297 | 299 | $arguments = func_get_args(); |
@@ -258,8 +258,9 @@ discard block |
||
258 | 258 | { |
259 | 259 | $queryStart++; |
260 | 260 | $queryEnd = strpos($sURL, '#', $queryStart); |
261 | - if ($queryEnd === FALSE) |
|
262 | - $queryEnd = strlen($sURL); |
|
261 | + if ($queryEnd === FALSE) { |
|
262 | + $queryEnd = strlen($sURL); |
|
263 | + } |
|
263 | 264 | $queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart); |
264 | 265 | $queryParts = array(); |
265 | 266 | parse_str($queryPart, $queryParts); |
@@ -487,8 +488,9 @@ discard block |
||
487 | 488 | function getXML() |
488 | 489 | { |
489 | 490 | $sXML = "<?xml version=\"1.0\""; |
490 | - if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
|
491 | - $sXML .= " encoding=\"".$this->sEncoding."\""; |
|
491 | + if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) { |
|
492 | + $sXML .= " encoding=\"".$this->sEncoding."\""; |
|
493 | + } |
|
492 | 494 | $sXML .= " ?"."><xjx>" . $this->xml . "</xjx>"; |
493 | 495 | |
494 | 496 | return $sXML; |
@@ -538,20 +540,21 @@ discard block |
||
538 | 540 | elseif (function_exists('mb_convert_encoding')) { |
539 | 541 | // |
540 | 542 | $sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding)); |
541 | - } |
|
542 | - else { |
|
543 | + } else { |
|
543 | 544 | trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE); |
544 | 545 | } |
545 | 546 | } |
546 | 547 | $xml = "<cmd"; |
547 | - foreach($aAttributes as $sAttribute => $sValue) |
|
548 | - $xml .= " $sAttribute=\"$sValue\""; |
|
549 | - if ($sData !== null && !stristr($sData,'<![CDATA[')) |
|
550 | - $xml .= "><![CDATA[$sData]]></cmd>"; |
|
551 | - else if ($sData !== null) |
|
552 | - $xml .= ">$sData</cmd>"; |
|
553 | - else |
|
554 | - $xml .= "></cmd>"; |
|
548 | + foreach($aAttributes as $sAttribute => $sValue) { |
|
549 | + $xml .= " $sAttribute=\"$sValue\""; |
|
550 | + } |
|
551 | + if ($sData !== null && !stristr($sData,'<![CDATA[')) { |
|
552 | + $xml .= "><![CDATA[$sData]]></cmd>"; |
|
553 | + } else if ($sData !== null) { |
|
554 | + $xml .= ">$sData</cmd>"; |
|
555 | + } else { |
|
556 | + $xml .= "></cmd>"; |
|
557 | + } |
|
555 | 558 | |
556 | 559 | return $xml; |
557 | 560 | } |
@@ -566,11 +569,12 @@ discard block |
||
566 | 569 | * @return string serialized XML |
567 | 570 | */ |
568 | 571 | function _buildObjXml($var) { |
569 | - if (gettype($var) == "object") $var = get_object_vars($var); |
|
572 | + if (gettype($var) == "object") { |
|
573 | + $var = get_object_vars($var); |
|
574 | + } |
|
570 | 575 | if (!is_array($var)) { |
571 | 576 | return "<![CDATA[$var]]>"; |
572 | - } |
|
573 | - else { |
|
577 | + } else { |
|
574 | 578 | $data = "<xjxobj>"; |
575 | 579 | foreach ($var as $key => $value) { |
576 | 580 | $data .= "<e>"; |
@@ -67,521 +67,521 @@ |
||
67 | 67 | */ |
68 | 68 | class xajaxResponse |
69 | 69 | { |
70 | - /**#@+ |
|
70 | + /**#@+ |
|
71 | 71 | * @access protected |
72 | 72 | */ |
73 | - /** |
|
74 | - * @var string internal XML storage |
|
75 | - */ |
|
76 | - var $xml; |
|
77 | - /** |
|
78 | - * @var string the encoding type to use |
|
79 | - */ |
|
80 | - var $sEncoding; |
|
81 | - /** |
|
82 | - * @var boolean if special characters in the XML should be converted to |
|
83 | - * entities |
|
84 | - */ |
|
85 | - var $bOutputEntities; |
|
86 | - |
|
87 | - /**#@-*/ |
|
88 | - |
|
89 | - /** |
|
90 | - * The constructor's main job is to set the character encoding for the |
|
91 | - * response. |
|
92 | - * |
|
93 | - * <i>Note:</i> to change the character encoding for all of the |
|
94 | - * responses, set the XAJAX_DEFAULT_ENCODING constant before you |
|
95 | - * instantiate xajax. |
|
96 | - * |
|
97 | - * @param string contains the character encoding string to use |
|
98 | - * @param boolean lets you set if you want special characters in the output |
|
99 | - * converted to HTML entities |
|
100 | - * |
|
101 | - */ |
|
102 | - public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false) |
|
103 | - { |
|
104 | - $this->setCharEncoding($sEncoding); |
|
105 | - $this->bOutputEntities = $bOutputEntities; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Sets the character encoding for the response based on $sEncoding, which |
|
110 | - * is a string containing the character encoding to use. You don't need to |
|
111 | - * use this method normally, since the character encoding for the response |
|
112 | - * gets set automatically based on the XAJAX_DEFAULT_CHAR_ENCODING |
|
113 | - * constant. |
|
114 | - * |
|
115 | - * @param string |
|
116 | - */ |
|
117 | - function setCharEncoding($sEncoding) |
|
118 | - { |
|
119 | - $this->sEncoding = $sEncoding; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Tells the response object to convert special characters to HTML entities |
|
124 | - * automatically (only works if the mb_string extension is available). |
|
125 | - */ |
|
126 | - function outputEntitiesOn() |
|
127 | - { |
|
128 | - $this->bOutputEntities = true; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Tells the response object to output special characters intact. (default |
|
133 | - * behavior) |
|
134 | - */ |
|
135 | - function outputEntitiesOff() |
|
136 | - { |
|
137 | - $this->bOutputEntities = false; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Adds a confirm commands command message to the XML response. |
|
142 | - * |
|
143 | - * <i>Usage:</i> <kbd>$objResponse->addConfirmCommands(1, "Do you want to preview the new data?");</kbd> |
|
144 | - * |
|
145 | - * @param integer the number of commands to skip if the user presses |
|
146 | - * Cancel in the browsers's confirm dialog |
|
147 | - * @param string the message to show in the browser's confirm dialog |
|
148 | - */ |
|
149 | - function addConfirmCommands($iCmdNumber, $sMessage) |
|
150 | - { |
|
151 | - $this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Adds an assign command message to the XML response. |
|
156 | - * |
|
157 | - * <i>Usage:</i> <kbd>$objResponse->addAssign("contentDiv", "innerHTML", "Some Text");</kbd> |
|
158 | - * |
|
159 | - * @param string contains the id of an HTML element |
|
160 | - * @param string the part of the element you wish to modify ("innerHTML", |
|
161 | - * "value", etc.) |
|
162 | - * @param string the data you want to set the attribute to |
|
163 | - */ |
|
164 | - function addAssign($sTarget,$sAttribute,$sData) |
|
165 | - { |
|
166 | - $this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * Adds an append command message to the XML response. |
|
171 | - * |
|
172 | - * <i>Usage:</i> <kbd>$objResponse->addAppend("contentDiv", "innerHTML", "Some New Text");</kbd> |
|
173 | - * |
|
174 | - * @param string contains the id of an HTML element |
|
175 | - * @param string the part of the element you wish to modify ("innerHTML", |
|
176 | - * "value", etc.) |
|
177 | - * @param string the data you want to append to the end of the attribute |
|
178 | - */ |
|
179 | - function addAppend($sTarget,$sAttribute,$sData) |
|
180 | - { |
|
181 | - $this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * Adds an prepend command message to the XML response. |
|
186 | - * |
|
187 | - * <i>Usage:</i> <kbd>$objResponse->addPrepend("contentDiv", "innerHTML", "Some Starting Text");</kbd> |
|
188 | - * |
|
189 | - * @param string contains the id of an HTML element |
|
190 | - * @param string the part of the element you wish to modify ("innerHTML", |
|
191 | - * "value", etc.) |
|
192 | - * @param string the data you want to prepend to the beginning of the |
|
193 | - * attribute |
|
194 | - */ |
|
195 | - function addPrepend($sTarget,$sAttribute,$sData) |
|
196 | - { |
|
197 | - $this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Adds a replace command message to the XML response. |
|
202 | - * |
|
203 | - * <i>Usage:</i> <kbd>$objResponse->addReplace("contentDiv", "innerHTML", "text", "<b>text</b>");</kbd> |
|
204 | - * |
|
205 | - * @param string contains the id of an HTML element |
|
206 | - * @param string the part of the element you wish to modify ("innerHTML", |
|
207 | - * "value", etc.) |
|
208 | - * @param string the string to search for |
|
209 | - * @param string the string to replace the search string when found in the |
|
210 | - * attribute |
|
211 | - */ |
|
212 | - function addReplace($sTarget,$sAttribute,$sSearch,$sData) |
|
213 | - { |
|
214 | - $sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>"; |
|
215 | - $this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta); |
|
216 | - } |
|
217 | - |
|
218 | - /** |
|
219 | - * Adds a clear command message to the XML response. |
|
220 | - * |
|
221 | - * <i>Usage:</i> <kbd>$objResponse->addClear("contentDiv", "innerHTML");</kbd> |
|
222 | - * |
|
223 | - * @param string contains the id of an HTML element |
|
224 | - * @param string the part of the element you wish to clear ("innerHTML", |
|
225 | - * "value", etc.) |
|
226 | - */ |
|
227 | - function addClear($sTarget,$sAttribute) |
|
228 | - { |
|
229 | - $this->addAssign($sTarget,$sAttribute,''); |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Adds an alert command message to the XML response. |
|
234 | - * |
|
235 | - * <i>Usage:</i> <kbd>$objResponse->addAlert("This is important information");</kbd> |
|
236 | - * |
|
237 | - * @param string the text to be displayed in the Javascript alert box |
|
238 | - */ |
|
239 | - function addAlert($sMsg) |
|
240 | - { |
|
241 | - $this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg); |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * Uses the addScript() method to add a Javascript redirect to another URL. |
|
246 | - * |
|
247 | - * <i>Usage:</i> <kbd>$objResponse->addRedirect("http://www.xajaxproject.org");</kbd> |
|
248 | - * |
|
249 | - * @param string the URL to redirect the client browser to |
|
250 | - */ |
|
251 | - function addRedirect($sURL) |
|
252 | - { |
|
253 | - //we need to parse the query part so that the values are rawurlencode()'ed |
|
254 | - //can't just use parse_url() cos we could be dealing with a relative URL which |
|
255 | - // parse_url() can't deal with. |
|
256 | - $queryStart = strpos($sURL, '?', strrpos($sURL, '/')); |
|
257 | - if ($queryStart !== FALSE) |
|
258 | - { |
|
259 | - $queryStart++; |
|
260 | - $queryEnd = strpos($sURL, '#', $queryStart); |
|
261 | - if ($queryEnd === FALSE) |
|
262 | - $queryEnd = strlen($sURL); |
|
263 | - $queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart); |
|
73 | + /** |
|
74 | + * @var string internal XML storage |
|
75 | + */ |
|
76 | + var $xml; |
|
77 | + /** |
|
78 | + * @var string the encoding type to use |
|
79 | + */ |
|
80 | + var $sEncoding; |
|
81 | + /** |
|
82 | + * @var boolean if special characters in the XML should be converted to |
|
83 | + * entities |
|
84 | + */ |
|
85 | + var $bOutputEntities; |
|
86 | + |
|
87 | + /**#@-*/ |
|
88 | + |
|
89 | + /** |
|
90 | + * The constructor's main job is to set the character encoding for the |
|
91 | + * response. |
|
92 | + * |
|
93 | + * <i>Note:</i> to change the character encoding for all of the |
|
94 | + * responses, set the XAJAX_DEFAULT_ENCODING constant before you |
|
95 | + * instantiate xajax. |
|
96 | + * |
|
97 | + * @param string contains the character encoding string to use |
|
98 | + * @param boolean lets you set if you want special characters in the output |
|
99 | + * converted to HTML entities |
|
100 | + * |
|
101 | + */ |
|
102 | + public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false) |
|
103 | + { |
|
104 | + $this->setCharEncoding($sEncoding); |
|
105 | + $this->bOutputEntities = $bOutputEntities; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Sets the character encoding for the response based on $sEncoding, which |
|
110 | + * is a string containing the character encoding to use. You don't need to |
|
111 | + * use this method normally, since the character encoding for the response |
|
112 | + * gets set automatically based on the XAJAX_DEFAULT_CHAR_ENCODING |
|
113 | + * constant. |
|
114 | + * |
|
115 | + * @param string |
|
116 | + */ |
|
117 | + function setCharEncoding($sEncoding) |
|
118 | + { |
|
119 | + $this->sEncoding = $sEncoding; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Tells the response object to convert special characters to HTML entities |
|
124 | + * automatically (only works if the mb_string extension is available). |
|
125 | + */ |
|
126 | + function outputEntitiesOn() |
|
127 | + { |
|
128 | + $this->bOutputEntities = true; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Tells the response object to output special characters intact. (default |
|
133 | + * behavior) |
|
134 | + */ |
|
135 | + function outputEntitiesOff() |
|
136 | + { |
|
137 | + $this->bOutputEntities = false; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Adds a confirm commands command message to the XML response. |
|
142 | + * |
|
143 | + * <i>Usage:</i> <kbd>$objResponse->addConfirmCommands(1, "Do you want to preview the new data?");</kbd> |
|
144 | + * |
|
145 | + * @param integer the number of commands to skip if the user presses |
|
146 | + * Cancel in the browsers's confirm dialog |
|
147 | + * @param string the message to show in the browser's confirm dialog |
|
148 | + */ |
|
149 | + function addConfirmCommands($iCmdNumber, $sMessage) |
|
150 | + { |
|
151 | + $this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Adds an assign command message to the XML response. |
|
156 | + * |
|
157 | + * <i>Usage:</i> <kbd>$objResponse->addAssign("contentDiv", "innerHTML", "Some Text");</kbd> |
|
158 | + * |
|
159 | + * @param string contains the id of an HTML element |
|
160 | + * @param string the part of the element you wish to modify ("innerHTML", |
|
161 | + * "value", etc.) |
|
162 | + * @param string the data you want to set the attribute to |
|
163 | + */ |
|
164 | + function addAssign($sTarget,$sAttribute,$sData) |
|
165 | + { |
|
166 | + $this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * Adds an append command message to the XML response. |
|
171 | + * |
|
172 | + * <i>Usage:</i> <kbd>$objResponse->addAppend("contentDiv", "innerHTML", "Some New Text");</kbd> |
|
173 | + * |
|
174 | + * @param string contains the id of an HTML element |
|
175 | + * @param string the part of the element you wish to modify ("innerHTML", |
|
176 | + * "value", etc.) |
|
177 | + * @param string the data you want to append to the end of the attribute |
|
178 | + */ |
|
179 | + function addAppend($sTarget,$sAttribute,$sData) |
|
180 | + { |
|
181 | + $this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * Adds an prepend command message to the XML response. |
|
186 | + * |
|
187 | + * <i>Usage:</i> <kbd>$objResponse->addPrepend("contentDiv", "innerHTML", "Some Starting Text");</kbd> |
|
188 | + * |
|
189 | + * @param string contains the id of an HTML element |
|
190 | + * @param string the part of the element you wish to modify ("innerHTML", |
|
191 | + * "value", etc.) |
|
192 | + * @param string the data you want to prepend to the beginning of the |
|
193 | + * attribute |
|
194 | + */ |
|
195 | + function addPrepend($sTarget,$sAttribute,$sData) |
|
196 | + { |
|
197 | + $this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Adds a replace command message to the XML response. |
|
202 | + * |
|
203 | + * <i>Usage:</i> <kbd>$objResponse->addReplace("contentDiv", "innerHTML", "text", "<b>text</b>");</kbd> |
|
204 | + * |
|
205 | + * @param string contains the id of an HTML element |
|
206 | + * @param string the part of the element you wish to modify ("innerHTML", |
|
207 | + * "value", etc.) |
|
208 | + * @param string the string to search for |
|
209 | + * @param string the string to replace the search string when found in the |
|
210 | + * attribute |
|
211 | + */ |
|
212 | + function addReplace($sTarget,$sAttribute,$sSearch,$sData) |
|
213 | + { |
|
214 | + $sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>"; |
|
215 | + $this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta); |
|
216 | + } |
|
217 | + |
|
218 | + /** |
|
219 | + * Adds a clear command message to the XML response. |
|
220 | + * |
|
221 | + * <i>Usage:</i> <kbd>$objResponse->addClear("contentDiv", "innerHTML");</kbd> |
|
222 | + * |
|
223 | + * @param string contains the id of an HTML element |
|
224 | + * @param string the part of the element you wish to clear ("innerHTML", |
|
225 | + * "value", etc.) |
|
226 | + */ |
|
227 | + function addClear($sTarget,$sAttribute) |
|
228 | + { |
|
229 | + $this->addAssign($sTarget,$sAttribute,''); |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Adds an alert command message to the XML response. |
|
234 | + * |
|
235 | + * <i>Usage:</i> <kbd>$objResponse->addAlert("This is important information");</kbd> |
|
236 | + * |
|
237 | + * @param string the text to be displayed in the Javascript alert box |
|
238 | + */ |
|
239 | + function addAlert($sMsg) |
|
240 | + { |
|
241 | + $this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg); |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * Uses the addScript() method to add a Javascript redirect to another URL. |
|
246 | + * |
|
247 | + * <i>Usage:</i> <kbd>$objResponse->addRedirect("http://www.xajaxproject.org");</kbd> |
|
248 | + * |
|
249 | + * @param string the URL to redirect the client browser to |
|
250 | + */ |
|
251 | + function addRedirect($sURL) |
|
252 | + { |
|
253 | + //we need to parse the query part so that the values are rawurlencode()'ed |
|
254 | + //can't just use parse_url() cos we could be dealing with a relative URL which |
|
255 | + // parse_url() can't deal with. |
|
256 | + $queryStart = strpos($sURL, '?', strrpos($sURL, '/')); |
|
257 | + if ($queryStart !== FALSE) |
|
258 | + { |
|
259 | + $queryStart++; |
|
260 | + $queryEnd = strpos($sURL, '#', $queryStart); |
|
261 | + if ($queryEnd === FALSE) |
|
262 | + $queryEnd = strlen($sURL); |
|
263 | + $queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart); |
|
264 | 264 | $queryParts = array(); |
265 | - parse_str($queryPart, $queryParts); |
|
266 | - $newQueryPart = ""; |
|
267 | - foreach($queryParts as $key => $value) |
|
268 | - { |
|
269 | - $newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output'); |
|
270 | - } |
|
271 | - $sURL = str_replace($queryPart, $newQueryPart, $sURL); |
|
272 | - } |
|
273 | - $this->addScript('window.location = "'.$sURL.'";'); |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * Adds a Javascript command message to the XML response. |
|
278 | - * |
|
279 | - * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd> |
|
280 | - * |
|
281 | - * @param string contains Javascript code to be executed |
|
282 | - */ |
|
283 | - function addScript($sJS) |
|
284 | - { |
|
285 | - $this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS); |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Adds a Javascript function call command message to the XML response. |
|
290 | - * |
|
291 | - * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd> |
|
292 | - * |
|
293 | - * @param string $sFunc the name of a Javascript function |
|
294 | - * @param mixed $args,... optional arguments to pass to the Javascript function |
|
295 | - */ |
|
296 | - function addScriptCall() { |
|
297 | - $arguments = func_get_args(); |
|
298 | - $sFunc = array_shift($arguments); |
|
299 | - $sData = $this->_buildObjXml($arguments); |
|
300 | - $this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData); |
|
301 | - } |
|
302 | - |
|
303 | - /** |
|
304 | - * Adds a remove element command message to the XML response. |
|
305 | - * |
|
306 | - * <i>Usage:</i> <kbd>$objResponse->addRemove("Div2");</kbd> |
|
307 | - * |
|
308 | - * @param string contains the id of an HTML element to be removed |
|
309 | - */ |
|
310 | - function addRemove($sTarget) |
|
311 | - { |
|
312 | - $this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),''); |
|
313 | - } |
|
314 | - |
|
315 | - /** |
|
316 | - * Adds a create element command message to the XML response. |
|
317 | - * |
|
318 | - * <i>Usage:</i> <kbd>$objResponse->addCreate("parentDiv", "h3", "myid");</kbd> |
|
319 | - * |
|
320 | - * @param string contains the id of an HTML element to to which the new |
|
321 | - * element will be appended. |
|
322 | - * @param string the tag to be added |
|
323 | - * @param string the id to be assigned to the new element |
|
324 | - * @param string deprecated, use the addCreateInput() method instead |
|
325 | - */ |
|
326 | - function addCreate($sParent, $sTag, $sId, $sType="") |
|
327 | - { |
|
328 | - if ($sType) |
|
329 | - { |
|
330 | - trigger_error("The \$sType parameter of addCreate has been deprecated. Use the addCreateInput() method instead.", E_USER_WARNING); |
|
331 | - return; |
|
332 | - } |
|
333 | - $this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag); |
|
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Adds a insert element command message to the XML response. |
|
338 | - * |
|
339 | - * <i>Usage:</i> <kbd>$objResponse->addInsert("childDiv", "h3", "myid");</kbd> |
|
340 | - * |
|
341 | - * @param string contains the id of the child before which the new element |
|
342 | - * will be inserted |
|
343 | - * @param string the tag to be added |
|
344 | - * @param string the id to be assigned to the new element |
|
345 | - */ |
|
346 | - function addInsert($sBefore, $sTag, $sId) |
|
347 | - { |
|
348 | - $this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag); |
|
349 | - } |
|
350 | - |
|
351 | - /** |
|
352 | - * Adds a insert element command message to the XML response. |
|
353 | - * |
|
354 | - * <i>Usage:</i> <kbd>$objResponse->addInsertAfter("childDiv", "h3", "myid");</kbd> |
|
355 | - * |
|
356 | - * @param string contains the id of the child after which the new element |
|
357 | - * will be inserted |
|
358 | - * @param string the tag to be added |
|
359 | - * @param string the id to be assigned to the new element |
|
360 | - */ |
|
361 | - function addInsertAfter($sAfter, $sTag, $sId) |
|
362 | - { |
|
363 | - $this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag); |
|
364 | - } |
|
365 | - |
|
366 | - /** |
|
367 | - * Adds a create input command message to the XML response. |
|
368 | - * |
|
369 | - * <i>Usage:</i> <kbd>$objResponse->addCreateInput("form1", "text", "username", "input1");</kbd> |
|
370 | - * |
|
371 | - * @param string contains the id of an HTML element to which the new input |
|
372 | - * will be appended |
|
373 | - * @param string the type of input to be created (text, radio, checkbox, |
|
374 | - * etc.) |
|
375 | - * @param string the name to be assigned to the new input and the variable |
|
376 | - * name when it is submitted |
|
377 | - * @param string the id to be assigned to the new input |
|
378 | - */ |
|
379 | - function addCreateInput($sParent, $sType, $sName, $sId) |
|
380 | - { |
|
381 | - $this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName); |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Adds an insert input command message to the XML response. |
|
386 | - * |
|
387 | - * <i>Usage:</i> <kbd>$objResponse->addInsertInput("input5", "text", "username", "input1");</kbd> |
|
388 | - * |
|
389 | - * @param string contains the id of the child before which the new element |
|
390 | - * will be inserted |
|
391 | - * @param string the type of input to be created (text, radio, checkbox, |
|
392 | - * etc.) |
|
393 | - * @param string the name to be assigned to the new input and the variable |
|
394 | - * name when it is submitted |
|
395 | - * @param string the id to be assigned to the new input |
|
396 | - */ |
|
397 | - function addInsertInput($sBefore, $sType, $sName, $sId) |
|
398 | - { |
|
399 | - $this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName); |
|
400 | - } |
|
401 | - |
|
402 | - /** |
|
403 | - * Adds an insert input command message to the XML response. |
|
404 | - * |
|
405 | - * <i>Usage:</i> <kbd>$objResponse->addInsertInputAfter("input7", "text", "email", "input2");</kbd> |
|
406 | - * |
|
407 | - * @param string contains the id of the child after which the new element |
|
408 | - * will be inserted |
|
409 | - * @param string the type of input to be created (text, radio, checkbox, |
|
410 | - * etc.) |
|
411 | - * @param string the name to be assigned to the new input and the variable |
|
412 | - * name when it is submitted |
|
413 | - * @param string the id to be assigned to the new input |
|
414 | - */ |
|
415 | - function addInsertInputAfter($sAfter, $sType, $sName, $sId) |
|
416 | - { |
|
417 | - $this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName); |
|
418 | - } |
|
419 | - |
|
420 | - /** |
|
421 | - * Adds an event command message to the XML response. |
|
422 | - * |
|
423 | - * <i>Usage:</i> <kbd>$objResponse->addEvent("contentDiv", "onclick", "alert(\'Hello World\');");</kbd> |
|
424 | - * |
|
425 | - * @param string contains the id of an HTML element |
|
426 | - * @param string the event you wish to set ("onclick", "onmouseover", etc.) |
|
427 | - * @param string the Javascript string you want the event to invoke |
|
428 | - */ |
|
429 | - function addEvent($sTarget,$sEvent,$sScript) |
|
430 | - { |
|
431 | - $this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript); |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Adds a handler command message to the XML response. |
|
436 | - * |
|
437 | - * <i>Usage:</i> <kbd>$objResponse->addHandler("contentDiv", "onclick", "content_click");</kbd> |
|
438 | - * |
|
439 | - * @param string contains the id of an HTML element |
|
440 | - * @param string the event you wish to set ("onclick", "onmouseover", etc.) |
|
441 | - * @param string the name of a Javascript function that will handle the |
|
442 | - * event. Multiple handlers can be added for the same event |
|
443 | - */ |
|
444 | - function addHandler($sTarget,$sEvent,$sHandler) |
|
445 | - { |
|
446 | - $this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler); |
|
447 | - } |
|
448 | - |
|
449 | - /** |
|
450 | - * Adds a remove handler command message to the XML response. |
|
451 | - * |
|
452 | - * <i>Usage:</i> <kbd>$objResponse->addRemoveHandler("contentDiv", "onclick", "content_click");</kbd> |
|
453 | - * |
|
454 | - * @param string contains the id of an HTML element |
|
455 | - * @param string the event you wish to remove ("onclick", "onmouseover", |
|
456 | - * etc.) |
|
457 | - * @param string the name of a Javascript handler function that you want to |
|
458 | - * remove |
|
459 | - */ |
|
460 | - function addRemoveHandler($sTarget,$sEvent,$sHandler) |
|
461 | - { |
|
462 | - $this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler); |
|
463 | - } |
|
464 | - |
|
465 | - /** |
|
466 | - * Adds an include script command message to the XML response. |
|
467 | - * |
|
468 | - * <i>Usage:</i> <kbd>$objResponse->addIncludeScript("functions.js");</kbd> |
|
469 | - * |
|
470 | - * @param string URL of the Javascript file to include |
|
471 | - */ |
|
472 | - function addIncludeScript($sFileName) |
|
473 | - { |
|
474 | - $this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName); |
|
475 | - } |
|
476 | - |
|
477 | - /** |
|
478 | - * Returns the XML to be returned from your function to the xajax processor |
|
479 | - * on your page. Since xajax 0.2, you can also return an xajaxResponse |
|
480 | - * object from your function directly, and xajax will automatically request |
|
481 | - * the XML using this method call. |
|
482 | - * |
|
483 | - * <i>Usage:</i> <kbd>return $objResponse->getXML();</kbd> |
|
484 | - * |
|
485 | - * @return string response XML data |
|
486 | - */ |
|
487 | - function getXML() |
|
488 | - { |
|
489 | - $sXML = "<?xml version=\"1.0\""; |
|
490 | - if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
|
491 | - $sXML .= " encoding=\"".$this->sEncoding."\""; |
|
492 | - $sXML .= " ?"."><xjx>" . $this->xml . "</xjx>"; |
|
493 | - |
|
494 | - return $sXML; |
|
495 | - } |
|
496 | - |
|
497 | - /** |
|
498 | - * Adds the commands of the provided response XML output to this response |
|
499 | - * object |
|
500 | - * |
|
501 | - * <i>Usage:</i> |
|
502 | - * <code>$r1 = $objResponse1->getXML(); |
|
503 | - * $objResponse2->loadXML($r1); |
|
504 | - * return $objResponse2->getXML();</code> |
|
505 | - * |
|
506 | - * @param string the response XML (returned from a getXML() method) to add |
|
507 | - * to the end of this response object |
|
508 | - */ |
|
509 | - function loadXML($mXML) |
|
510 | - { |
|
511 | - if (is_a($mXML, "xajaxResponse")) { |
|
512 | - $mXML = $mXML->getXML(); |
|
513 | - } |
|
514 | - $sNewXML = ""; |
|
515 | - $iStartPos = strpos($mXML, "<xjx>") + 5; |
|
516 | - $sNewXML = substr($mXML, $iStartPos); |
|
517 | - $iEndPos = strpos($sNewXML, "</xjx>"); |
|
518 | - $sNewXML = substr($sNewXML, 0, $iEndPos); |
|
519 | - $this->xml .= $sNewXML; |
|
520 | - } |
|
521 | - |
|
522 | - /** |
|
523 | - * Generates XML from command data |
|
524 | - * |
|
525 | - * @access private |
|
526 | - * @param array associative array of attributes |
|
527 | - * @param string data |
|
528 | - * @return string XML command |
|
529 | - */ |
|
530 | - function _cmdXML($aAttributes, $sData) |
|
531 | - { |
|
532 | - if ($this->bOutputEntities) { |
|
533 | - // An adaptation for the Dokeos LMS, 22-AUG-2009. |
|
534 | - if (function_exists('api_convert_encoding')) { |
|
535 | - $sData = call_user_func_array('api_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding)); |
|
536 | - } |
|
537 | - //if (function_exists('mb_convert_encoding')) { |
|
538 | - elseif (function_exists('mb_convert_encoding')) { |
|
539 | - // |
|
540 | - $sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding)); |
|
541 | - } |
|
542 | - else { |
|
543 | - trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE); |
|
544 | - } |
|
545 | - } |
|
546 | - $xml = "<cmd"; |
|
547 | - foreach($aAttributes as $sAttribute => $sValue) |
|
548 | - $xml .= " $sAttribute=\"$sValue\""; |
|
549 | - if ($sData !== null && !stristr($sData,'<![CDATA[')) |
|
550 | - $xml .= "><![CDATA[$sData]]></cmd>"; |
|
551 | - else if ($sData !== null) |
|
552 | - $xml .= ">$sData</cmd>"; |
|
553 | - else |
|
554 | - $xml .= "></cmd>"; |
|
555 | - |
|
556 | - return $xml; |
|
557 | - } |
|
558 | - |
|
559 | - /** |
|
560 | - * Recursively serializes a data structure in XML so it can be sent to |
|
561 | - * the client. It could be thought of as the opposite of |
|
562 | - * {@link xajax::_parseObjXml()}. |
|
563 | - * |
|
564 | - * @access private |
|
565 | - * @param mixed data structure to serialize to XML |
|
566 | - * @return string serialized XML |
|
567 | - */ |
|
568 | - function _buildObjXml($var) { |
|
569 | - if (gettype($var) == "object") $var = get_object_vars($var); |
|
570 | - if (!is_array($var)) { |
|
571 | - return "<![CDATA[$var]]>"; |
|
572 | - } |
|
573 | - else { |
|
574 | - $data = "<xjxobj>"; |
|
575 | - foreach ($var as $key => $value) { |
|
576 | - $data .= "<e>"; |
|
577 | - $data .= "<k>" . htmlspecialchars($key) . "</k>"; |
|
578 | - $data .= "<v>" . $this->_buildObjXml($value) . "</v>"; |
|
579 | - $data .= "</e>"; |
|
580 | - } |
|
581 | - $data .= "</xjxobj>"; |
|
582 | - return $data; |
|
583 | - } |
|
584 | - } |
|
265 | + parse_str($queryPart, $queryParts); |
|
266 | + $newQueryPart = ""; |
|
267 | + foreach($queryParts as $key => $value) |
|
268 | + { |
|
269 | + $newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output'); |
|
270 | + } |
|
271 | + $sURL = str_replace($queryPart, $newQueryPart, $sURL); |
|
272 | + } |
|
273 | + $this->addScript('window.location = "'.$sURL.'";'); |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * Adds a Javascript command message to the XML response. |
|
278 | + * |
|
279 | + * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd> |
|
280 | + * |
|
281 | + * @param string contains Javascript code to be executed |
|
282 | + */ |
|
283 | + function addScript($sJS) |
|
284 | + { |
|
285 | + $this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS); |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Adds a Javascript function call command message to the XML response. |
|
290 | + * |
|
291 | + * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd> |
|
292 | + * |
|
293 | + * @param string $sFunc the name of a Javascript function |
|
294 | + * @param mixed $args,... optional arguments to pass to the Javascript function |
|
295 | + */ |
|
296 | + function addScriptCall() { |
|
297 | + $arguments = func_get_args(); |
|
298 | + $sFunc = array_shift($arguments); |
|
299 | + $sData = $this->_buildObjXml($arguments); |
|
300 | + $this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData); |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Adds a remove element command message to the XML response. |
|
305 | + * |
|
306 | + * <i>Usage:</i> <kbd>$objResponse->addRemove("Div2");</kbd> |
|
307 | + * |
|
308 | + * @param string contains the id of an HTML element to be removed |
|
309 | + */ |
|
310 | + function addRemove($sTarget) |
|
311 | + { |
|
312 | + $this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),''); |
|
313 | + } |
|
314 | + |
|
315 | + /** |
|
316 | + * Adds a create element command message to the XML response. |
|
317 | + * |
|
318 | + * <i>Usage:</i> <kbd>$objResponse->addCreate("parentDiv", "h3", "myid");</kbd> |
|
319 | + * |
|
320 | + * @param string contains the id of an HTML element to to which the new |
|
321 | + * element will be appended. |
|
322 | + * @param string the tag to be added |
|
323 | + * @param string the id to be assigned to the new element |
|
324 | + * @param string deprecated, use the addCreateInput() method instead |
|
325 | + */ |
|
326 | + function addCreate($sParent, $sTag, $sId, $sType="") |
|
327 | + { |
|
328 | + if ($sType) |
|
329 | + { |
|
330 | + trigger_error("The \$sType parameter of addCreate has been deprecated. Use the addCreateInput() method instead.", E_USER_WARNING); |
|
331 | + return; |
|
332 | + } |
|
333 | + $this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag); |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Adds a insert element command message to the XML response. |
|
338 | + * |
|
339 | + * <i>Usage:</i> <kbd>$objResponse->addInsert("childDiv", "h3", "myid");</kbd> |
|
340 | + * |
|
341 | + * @param string contains the id of the child before which the new element |
|
342 | + * will be inserted |
|
343 | + * @param string the tag to be added |
|
344 | + * @param string the id to be assigned to the new element |
|
345 | + */ |
|
346 | + function addInsert($sBefore, $sTag, $sId) |
|
347 | + { |
|
348 | + $this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag); |
|
349 | + } |
|
350 | + |
|
351 | + /** |
|
352 | + * Adds a insert element command message to the XML response. |
|
353 | + * |
|
354 | + * <i>Usage:</i> <kbd>$objResponse->addInsertAfter("childDiv", "h3", "myid");</kbd> |
|
355 | + * |
|
356 | + * @param string contains the id of the child after which the new element |
|
357 | + * will be inserted |
|
358 | + * @param string the tag to be added |
|
359 | + * @param string the id to be assigned to the new element |
|
360 | + */ |
|
361 | + function addInsertAfter($sAfter, $sTag, $sId) |
|
362 | + { |
|
363 | + $this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag); |
|
364 | + } |
|
365 | + |
|
366 | + /** |
|
367 | + * Adds a create input command message to the XML response. |
|
368 | + * |
|
369 | + * <i>Usage:</i> <kbd>$objResponse->addCreateInput("form1", "text", "username", "input1");</kbd> |
|
370 | + * |
|
371 | + * @param string contains the id of an HTML element to which the new input |
|
372 | + * will be appended |
|
373 | + * @param string the type of input to be created (text, radio, checkbox, |
|
374 | + * etc.) |
|
375 | + * @param string the name to be assigned to the new input and the variable |
|
376 | + * name when it is submitted |
|
377 | + * @param string the id to be assigned to the new input |
|
378 | + */ |
|
379 | + function addCreateInput($sParent, $sType, $sName, $sId) |
|
380 | + { |
|
381 | + $this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName); |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Adds an insert input command message to the XML response. |
|
386 | + * |
|
387 | + * <i>Usage:</i> <kbd>$objResponse->addInsertInput("input5", "text", "username", "input1");</kbd> |
|
388 | + * |
|
389 | + * @param string contains the id of the child before which the new element |
|
390 | + * will be inserted |
|
391 | + * @param string the type of input to be created (text, radio, checkbox, |
|
392 | + * etc.) |
|
393 | + * @param string the name to be assigned to the new input and the variable |
|
394 | + * name when it is submitted |
|
395 | + * @param string the id to be assigned to the new input |
|
396 | + */ |
|
397 | + function addInsertInput($sBefore, $sType, $sName, $sId) |
|
398 | + { |
|
399 | + $this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName); |
|
400 | + } |
|
401 | + |
|
402 | + /** |
|
403 | + * Adds an insert input command message to the XML response. |
|
404 | + * |
|
405 | + * <i>Usage:</i> <kbd>$objResponse->addInsertInputAfter("input7", "text", "email", "input2");</kbd> |
|
406 | + * |
|
407 | + * @param string contains the id of the child after which the new element |
|
408 | + * will be inserted |
|
409 | + * @param string the type of input to be created (text, radio, checkbox, |
|
410 | + * etc.) |
|
411 | + * @param string the name to be assigned to the new input and the variable |
|
412 | + * name when it is submitted |
|
413 | + * @param string the id to be assigned to the new input |
|
414 | + */ |
|
415 | + function addInsertInputAfter($sAfter, $sType, $sName, $sId) |
|
416 | + { |
|
417 | + $this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName); |
|
418 | + } |
|
419 | + |
|
420 | + /** |
|
421 | + * Adds an event command message to the XML response. |
|
422 | + * |
|
423 | + * <i>Usage:</i> <kbd>$objResponse->addEvent("contentDiv", "onclick", "alert(\'Hello World\');");</kbd> |
|
424 | + * |
|
425 | + * @param string contains the id of an HTML element |
|
426 | + * @param string the event you wish to set ("onclick", "onmouseover", etc.) |
|
427 | + * @param string the Javascript string you want the event to invoke |
|
428 | + */ |
|
429 | + function addEvent($sTarget,$sEvent,$sScript) |
|
430 | + { |
|
431 | + $this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript); |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Adds a handler command message to the XML response. |
|
436 | + * |
|
437 | + * <i>Usage:</i> <kbd>$objResponse->addHandler("contentDiv", "onclick", "content_click");</kbd> |
|
438 | + * |
|
439 | + * @param string contains the id of an HTML element |
|
440 | + * @param string the event you wish to set ("onclick", "onmouseover", etc.) |
|
441 | + * @param string the name of a Javascript function that will handle the |
|
442 | + * event. Multiple handlers can be added for the same event |
|
443 | + */ |
|
444 | + function addHandler($sTarget,$sEvent,$sHandler) |
|
445 | + { |
|
446 | + $this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler); |
|
447 | + } |
|
448 | + |
|
449 | + /** |
|
450 | + * Adds a remove handler command message to the XML response. |
|
451 | + * |
|
452 | + * <i>Usage:</i> <kbd>$objResponse->addRemoveHandler("contentDiv", "onclick", "content_click");</kbd> |
|
453 | + * |
|
454 | + * @param string contains the id of an HTML element |
|
455 | + * @param string the event you wish to remove ("onclick", "onmouseover", |
|
456 | + * etc.) |
|
457 | + * @param string the name of a Javascript handler function that you want to |
|
458 | + * remove |
|
459 | + */ |
|
460 | + function addRemoveHandler($sTarget,$sEvent,$sHandler) |
|
461 | + { |
|
462 | + $this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler); |
|
463 | + } |
|
464 | + |
|
465 | + /** |
|
466 | + * Adds an include script command message to the XML response. |
|
467 | + * |
|
468 | + * <i>Usage:</i> <kbd>$objResponse->addIncludeScript("functions.js");</kbd> |
|
469 | + * |
|
470 | + * @param string URL of the Javascript file to include |
|
471 | + */ |
|
472 | + function addIncludeScript($sFileName) |
|
473 | + { |
|
474 | + $this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName); |
|
475 | + } |
|
476 | + |
|
477 | + /** |
|
478 | + * Returns the XML to be returned from your function to the xajax processor |
|
479 | + * on your page. Since xajax 0.2, you can also return an xajaxResponse |
|
480 | + * object from your function directly, and xajax will automatically request |
|
481 | + * the XML using this method call. |
|
482 | + * |
|
483 | + * <i>Usage:</i> <kbd>return $objResponse->getXML();</kbd> |
|
484 | + * |
|
485 | + * @return string response XML data |
|
486 | + */ |
|
487 | + function getXML() |
|
488 | + { |
|
489 | + $sXML = "<?xml version=\"1.0\""; |
|
490 | + if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
|
491 | + $sXML .= " encoding=\"".$this->sEncoding."\""; |
|
492 | + $sXML .= " ?"."><xjx>" . $this->xml . "</xjx>"; |
|
493 | + |
|
494 | + return $sXML; |
|
495 | + } |
|
496 | + |
|
497 | + /** |
|
498 | + * Adds the commands of the provided response XML output to this response |
|
499 | + * object |
|
500 | + * |
|
501 | + * <i>Usage:</i> |
|
502 | + * <code>$r1 = $objResponse1->getXML(); |
|
503 | + * $objResponse2->loadXML($r1); |
|
504 | + * return $objResponse2->getXML();</code> |
|
505 | + * |
|
506 | + * @param string the response XML (returned from a getXML() method) to add |
|
507 | + * to the end of this response object |
|
508 | + */ |
|
509 | + function loadXML($mXML) |
|
510 | + { |
|
511 | + if (is_a($mXML, "xajaxResponse")) { |
|
512 | + $mXML = $mXML->getXML(); |
|
513 | + } |
|
514 | + $sNewXML = ""; |
|
515 | + $iStartPos = strpos($mXML, "<xjx>") + 5; |
|
516 | + $sNewXML = substr($mXML, $iStartPos); |
|
517 | + $iEndPos = strpos($sNewXML, "</xjx>"); |
|
518 | + $sNewXML = substr($sNewXML, 0, $iEndPos); |
|
519 | + $this->xml .= $sNewXML; |
|
520 | + } |
|
521 | + |
|
522 | + /** |
|
523 | + * Generates XML from command data |
|
524 | + * |
|
525 | + * @access private |
|
526 | + * @param array associative array of attributes |
|
527 | + * @param string data |
|
528 | + * @return string XML command |
|
529 | + */ |
|
530 | + function _cmdXML($aAttributes, $sData) |
|
531 | + { |
|
532 | + if ($this->bOutputEntities) { |
|
533 | + // An adaptation for the Dokeos LMS, 22-AUG-2009. |
|
534 | + if (function_exists('api_convert_encoding')) { |
|
535 | + $sData = call_user_func_array('api_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding)); |
|
536 | + } |
|
537 | + //if (function_exists('mb_convert_encoding')) { |
|
538 | + elseif (function_exists('mb_convert_encoding')) { |
|
539 | + // |
|
540 | + $sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding)); |
|
541 | + } |
|
542 | + else { |
|
543 | + trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE); |
|
544 | + } |
|
545 | + } |
|
546 | + $xml = "<cmd"; |
|
547 | + foreach($aAttributes as $sAttribute => $sValue) |
|
548 | + $xml .= " $sAttribute=\"$sValue\""; |
|
549 | + if ($sData !== null && !stristr($sData,'<![CDATA[')) |
|
550 | + $xml .= "><![CDATA[$sData]]></cmd>"; |
|
551 | + else if ($sData !== null) |
|
552 | + $xml .= ">$sData</cmd>"; |
|
553 | + else |
|
554 | + $xml .= "></cmd>"; |
|
555 | + |
|
556 | + return $xml; |
|
557 | + } |
|
558 | + |
|
559 | + /** |
|
560 | + * Recursively serializes a data structure in XML so it can be sent to |
|
561 | + * the client. It could be thought of as the opposite of |
|
562 | + * {@link xajax::_parseObjXml()}. |
|
563 | + * |
|
564 | + * @access private |
|
565 | + * @param mixed data structure to serialize to XML |
|
566 | + * @return string serialized XML |
|
567 | + */ |
|
568 | + function _buildObjXml($var) { |
|
569 | + if (gettype($var) == "object") $var = get_object_vars($var); |
|
570 | + if (!is_array($var)) { |
|
571 | + return "<![CDATA[$var]]>"; |
|
572 | + } |
|
573 | + else { |
|
574 | + $data = "<xjxobj>"; |
|
575 | + foreach ($var as $key => $value) { |
|
576 | + $data .= "<e>"; |
|
577 | + $data .= "<k>" . htmlspecialchars($key) . "</k>"; |
|
578 | + $data .= "<v>" . $this->_buildObjXml($value) . "</v>"; |
|
579 | + $data .= "</e>"; |
|
580 | + } |
|
581 | + $data .= "</xjxobj>"; |
|
582 | + return $data; |
|
583 | + } |
|
584 | + } |
|
585 | 585 | |
586 | 586 | }// end class xajaxResponse |
587 | 587 | ?> |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * converted to HTML entities |
100 | 100 | * |
101 | 101 | */ |
102 | - public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false) |
|
102 | + public function __construct($sEncoding = XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities = false) |
|
103 | 103 | { |
104 | 104 | $this->setCharEncoding($sEncoding); |
105 | 105 | $this->bOutputEntities = $bOutputEntities; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | function addConfirmCommands($iCmdNumber, $sMessage) |
150 | 150 | { |
151 | - $this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage); |
|
151 | + $this->xml .= $this->_cmdXML(array("n"=>"cc", "t"=>$iCmdNumber), $sMessage); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * "value", etc.) |
162 | 162 | * @param string the data you want to set the attribute to |
163 | 163 | */ |
164 | - function addAssign($sTarget,$sAttribute,$sData) |
|
164 | + function addAssign($sTarget, $sAttribute, $sData) |
|
165 | 165 | { |
166 | - $this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
166 | + $this->xml .= $this->_cmdXML(array("n"=>"as", "t"=>$sTarget, "p"=>$sAttribute), $sData); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | * "value", etc.) |
177 | 177 | * @param string the data you want to append to the end of the attribute |
178 | 178 | */ |
179 | - function addAppend($sTarget,$sAttribute,$sData) |
|
179 | + function addAppend($sTarget, $sAttribute, $sData) |
|
180 | 180 | { |
181 | - $this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
181 | + $this->xml .= $this->_cmdXML(array("n"=>"ap", "t"=>$sTarget, "p"=>$sAttribute), $sData); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | * @param string the data you want to prepend to the beginning of the |
193 | 193 | * attribute |
194 | 194 | */ |
195 | - function addPrepend($sTarget,$sAttribute,$sData) |
|
195 | + function addPrepend($sTarget, $sAttribute, $sData) |
|
196 | 196 | { |
197 | - $this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
197 | + $this->xml .= $this->_cmdXML(array("n"=>"pp", "t"=>$sTarget, "p"=>$sAttribute), $sData); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | * @param string the string to replace the search string when found in the |
210 | 210 | * attribute |
211 | 211 | */ |
212 | - function addReplace($sTarget,$sAttribute,$sSearch,$sData) |
|
212 | + function addReplace($sTarget, $sAttribute, $sSearch, $sData) |
|
213 | 213 | { |
214 | 214 | $sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>"; |
215 | - $this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta); |
|
215 | + $this->xml .= $this->_cmdXML(array("n"=>"rp", "t"=>$sTarget, "p"=>$sAttribute), $sDta); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | * @param string the part of the element you wish to clear ("innerHTML", |
225 | 225 | * "value", etc.) |
226 | 226 | */ |
227 | - function addClear($sTarget,$sAttribute) |
|
227 | + function addClear($sTarget, $sAttribute) |
|
228 | 228 | { |
229 | - $this->addAssign($sTarget,$sAttribute,''); |
|
229 | + $this->addAssign($sTarget, $sAttribute, ''); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | function addAlert($sMsg) |
240 | 240 | { |
241 | - $this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg); |
|
241 | + $this->xml .= $this->_cmdXML(array("n"=>"al"), $sMsg); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | $queryEnd = strpos($sURL, '#', $queryStart); |
261 | 261 | if ($queryEnd === FALSE) |
262 | 262 | $queryEnd = strlen($sURL); |
263 | - $queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart); |
|
263 | + $queryPart = substr($sURL, $queryStart, $queryEnd - $queryStart); |
|
264 | 264 | $queryParts = array(); |
265 | 265 | parse_str($queryPart, $queryParts); |
266 | 266 | $newQueryPart = ""; |
267 | - foreach($queryParts as $key => $value) |
|
267 | + foreach ($queryParts as $key => $value) |
|
268 | 268 | { |
269 | 269 | $newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output'); |
270 | 270 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | */ |
283 | 283 | function addScript($sJS) |
284 | 284 | { |
285 | - $this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS); |
|
285 | + $this->xml .= $this->_cmdXML(array("n"=>"js"), $sJS); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $arguments = func_get_args(); |
298 | 298 | $sFunc = array_shift($arguments); |
299 | 299 | $sData = $this->_buildObjXml($arguments); |
300 | - $this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData); |
|
300 | + $this->xml .= $this->_cmdXML(array("n"=>"jc", "t"=>$sFunc), $sData); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | */ |
310 | 310 | function addRemove($sTarget) |
311 | 311 | { |
312 | - $this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),''); |
|
312 | + $this->xml .= $this->_cmdXML(array("n"=>"rm", "t"=>$sTarget), ''); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -323,14 +323,14 @@ discard block |
||
323 | 323 | * @param string the id to be assigned to the new element |
324 | 324 | * @param string deprecated, use the addCreateInput() method instead |
325 | 325 | */ |
326 | - function addCreate($sParent, $sTag, $sId, $sType="") |
|
326 | + function addCreate($sParent, $sTag, $sId, $sType = "") |
|
327 | 327 | { |
328 | 328 | if ($sType) |
329 | 329 | { |
330 | 330 | trigger_error("The \$sType parameter of addCreate has been deprecated. Use the addCreateInput() method instead.", E_USER_WARNING); |
331 | 331 | return; |
332 | 332 | } |
333 | - $this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag); |
|
333 | + $this->xml .= $this->_cmdXML(array("n"=>"ce", "t"=>$sParent, "p"=>$sId), $sTag); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | */ |
346 | 346 | function addInsert($sBefore, $sTag, $sId) |
347 | 347 | { |
348 | - $this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag); |
|
348 | + $this->xml .= $this->_cmdXML(array("n"=>"ie", "t"=>$sBefore, "p"=>$sId), $sTag); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | */ |
361 | 361 | function addInsertAfter($sAfter, $sTag, $sId) |
362 | 362 | { |
363 | - $this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag); |
|
363 | + $this->xml .= $this->_cmdXML(array("n"=>"ia", "t"=>$sAfter, "p"=>$sId), $sTag); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | */ |
379 | 379 | function addCreateInput($sParent, $sType, $sName, $sId) |
380 | 380 | { |
381 | - $this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName); |
|
381 | + $this->xml .= $this->_cmdXML(array("n"=>"ci", "t"=>$sParent, "p"=>$sId, "c"=>$sType), $sName); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | */ |
397 | 397 | function addInsertInput($sBefore, $sType, $sName, $sId) |
398 | 398 | { |
399 | - $this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName); |
|
399 | + $this->xml .= $this->_cmdXML(array("n"=>"ii", "t"=>$sBefore, "p"=>$sId, "c"=>$sType), $sName); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | */ |
415 | 415 | function addInsertInputAfter($sAfter, $sType, $sName, $sId) |
416 | 416 | { |
417 | - $this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName); |
|
417 | + $this->xml .= $this->_cmdXML(array("n"=>"iia", "t"=>$sAfter, "p"=>$sId, "c"=>$sType), $sName); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -426,9 +426,9 @@ discard block |
||
426 | 426 | * @param string the event you wish to set ("onclick", "onmouseover", etc.) |
427 | 427 | * @param string the Javascript string you want the event to invoke |
428 | 428 | */ |
429 | - function addEvent($sTarget,$sEvent,$sScript) |
|
429 | + function addEvent($sTarget, $sEvent, $sScript) |
|
430 | 430 | { |
431 | - $this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript); |
|
431 | + $this->xml .= $this->_cmdXML(array("n"=>"ev", "t"=>$sTarget, "p"=>$sEvent), $sScript); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | * @param string the name of a Javascript function that will handle the |
442 | 442 | * event. Multiple handlers can be added for the same event |
443 | 443 | */ |
444 | - function addHandler($sTarget,$sEvent,$sHandler) |
|
444 | + function addHandler($sTarget, $sEvent, $sHandler) |
|
445 | 445 | { |
446 | - $this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler); |
|
446 | + $this->xml .= $this->_cmdXML(array("n"=>"ah", "t"=>$sTarget, "p"=>$sEvent), $sHandler); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | * @param string the name of a Javascript handler function that you want to |
458 | 458 | * remove |
459 | 459 | */ |
460 | - function addRemoveHandler($sTarget,$sEvent,$sHandler) |
|
460 | + function addRemoveHandler($sTarget, $sEvent, $sHandler) |
|
461 | 461 | { |
462 | - $this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler); |
|
462 | + $this->xml .= $this->_cmdXML(array("n"=>"rh", "t"=>$sTarget, "p"=>$sEvent), $sHandler); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | function addIncludeScript($sFileName) |
473 | 473 | { |
474 | - $this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName); |
|
474 | + $this->xml .= $this->_cmdXML(array("n"=>"in"), $sFileName); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | $sXML = "<?xml version=\"1.0\""; |
490 | 490 | if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
491 | 491 | $sXML .= " encoding=\"".$this->sEncoding."\""; |
492 | - $sXML .= " ?"."><xjx>" . $this->xml . "</xjx>"; |
|
492 | + $sXML .= " ?"."><xjx>".$this->xml."</xjx>"; |
|
493 | 493 | |
494 | 494 | return $sXML; |
495 | 495 | } |
@@ -544,9 +544,9 @@ discard block |
||
544 | 544 | } |
545 | 545 | } |
546 | 546 | $xml = "<cmd"; |
547 | - foreach($aAttributes as $sAttribute => $sValue) |
|
547 | + foreach ($aAttributes as $sAttribute => $sValue) |
|
548 | 548 | $xml .= " $sAttribute=\"$sValue\""; |
549 | - if ($sData !== null && !stristr($sData,'<![CDATA[')) |
|
549 | + if ($sData !== null && !stristr($sData, '<![CDATA[')) |
|
550 | 550 | $xml .= "><![CDATA[$sData]]></cmd>"; |
551 | 551 | else if ($sData !== null) |
552 | 552 | $xml .= ">$sData</cmd>"; |
@@ -574,8 +574,8 @@ discard block |
||
574 | 574 | $data = "<xjxobj>"; |
575 | 575 | foreach ($var as $key => $value) { |
576 | 576 | $data .= "<e>"; |
577 | - $data .= "<k>" . htmlspecialchars($key) . "</k>"; |
|
578 | - $data .= "<v>" . $this->_buildObjXml($value) . "</v>"; |
|
577 | + $data .= "<k>".htmlspecialchars($key)."</k>"; |
|
578 | + $data .= "<v>".$this->_buildObjXml($value)."</v>"; |
|
579 | 579 | $data .= "</e>"; |
580 | 580 | } |
581 | 581 | $data .= "</xjxobj>"; |
@@ -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; |