From 3eec106c8a1733879c6a4ede4df18afb3a022c96 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 2 Dec 2014 10:12:01 -0500 Subject: [PATCH] CRM-15674 - API rest code cleanup --- CRM/Utils/REST.php | 11 ++++------- extern/rest.php | 9 +++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index 859e32d113..1f6dd5ec53 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -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 = " diff --git a/extern/rest.php b/extern/rest.php index 57863642f4..8d4e6ad9c1 100644 --- a/extern/rest.php +++ b/extern/rest.php @@ -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(); -- 2.25.1