protected function encodeData($data) { global $arr_response; if ($_REQUEST['response_format'] == 'xml') { header('Content-type: text/xml'); $response = SiteLibrary::array2xml($arr_response); } else { //Do a pretty print if available in the running php/json version compilation if ($_REQUEST['response_print'] == 'pretty') { if (defined(JSON_PRETTY_PRINT)) { $response = json_encode($arr_response, JSON_PRETTY_PRINT); } else { $response = json_encode($arr_response); } } else { $response = json_encode($arr_response); } if (isset($_REQUEST['callback'])) { header('Content-type: application/x-javascript'); $response = $_REQUEST['callback'] . '(' . $response . ')'; } else { header('Content-type: text/plain'); } } return $response; }