Commit 3eec106c authored by colemanw's avatar colemanw

CRM-15674 - API rest code cleanup

parent db551313
......@@ -145,10 +145,11 @@ class CRM_Utils_REST {
$result = self::error('Could not interpret return values from function.');
}
if (CRM_Utils_Array::value('json', $requestParams)) {
header('Content-Type: text/javascript');
if (!empty($requestParams['json'])) {
header('Content-Type: application/json');
$json = json_encode(array_merge($result));
if (CRM_Utils_Array::value('prettyprint', $requestParams)) {
if (!empty($requestParams['prettyprint'])) {
// Used by the api explorer
return self::jsonFormated($json);
}
return $json;
......@@ -156,11 +157,7 @@ class CRM_Utils_REST {
if (isset($result['count'])) {
$count = ' count="' . $result['count'] . '" ';
}
else $count = "";
$xml = "<?xml version=\"1.0\"?>
......
......@@ -26,17 +26,14 @@
*/
require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
session_start();
require_once 'CRM/Utils/REST.php';
$rest = new CRM_Utils_REST();
if (isset($_GET['json']) && $_GET['json']) {
header('Content-Type: text/javascript');
}
else {
// Json-appropriate header will be set by CRM_Utils_Rest
// But we need to set header here for non-json
if (empty($_GET['json'])) {
header('Content-Type: text/xml');
}
echo $rest->bootAndRun();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment