From b308e50d40558a64a0d795b1cb7d5f7aa3876e17 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 7 Aug 2015 20:04:46 -0400 Subject: [PATCH] CRM-12527 - Show devel footer in api explorer output --- CRM/Utils/REST.php | 4 ++-- templates/CRM/Admin/Page/APIExplorer.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index b5b3880ed4..f00f96a3af 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -145,11 +145,11 @@ class CRM_Utils_REST { } if (!empty($requestParams['json'])) { - CRM_Utils_System::setHttpHeader('Content-Type', 'application/json'); if (!empty($requestParams['prettyprint'])) { - // Used by the api explorer + // Don't set content-type header for api explorer output return self::jsonFormated(array_merge($result)); } + CRM_Utils_System::setHttpHeader('Content-Type', 'application/json'); return json_encode(array_merge($result)); } diff --git a/templates/CRM/Admin/Page/APIExplorer.js b/templates/CRM/Admin/Page/APIExplorer.js index 35a7701c7b..1c8499dc46 100644 --- a/templates/CRM/Admin/Page/APIExplorer.js +++ b/templates/CRM/Admin/Page/APIExplorer.js @@ -610,6 +610,7 @@ * Note: We have to manually execute the ajax in order to add the secret extra "prettyprint" param */ function execute() { + var footer; $('#api-result').html('
'); $.ajax({ url: CRM.url('civicrm/ajax/rest'), @@ -622,8 +623,17 @@ type: _.includes(action, 'get') ? 'GET' : 'POST', dataType: 'text' }).done(function(text) { + // There may be debug information appended to the end of the json string + var footerPos = text.indexOf("\n}<"); + if (footerPos) { + footer = text.substr(footerPos + 2); + text = text.substr(0, footerPos + 2); + } $('#api-result').text(text); prettyPrint('#api-result'); + if (footer) { + $('#api-result').append(footer); + } }); } -- 2.25.1