From da251228cbb54818852c49d37ec7eb31f2313160 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 13 Feb 2010 13:44:09 -0800 Subject: If the return object is empty still return the empty object in the json response. --- modules/rest/helpers/rest.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'modules/rest/helpers') diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index a61aba2f..3c53784d 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -21,17 +21,15 @@ class rest_Core { static function reply($data=array()) { Session::instance()->abort_save(); - if ($data) { - if (Input::instance()->get("output") == "html") { - header("Content-type: text/html"); - $html = preg_replace( - "#([\w]+?://[\w]+[^ \'\"\n\r\t<]*)#ise", "'\\1'", - var_export($data, 1)); - print "
$html
"; - } else { - header("Content-type: application/json"); - print json_encode($data); - } + if (Input::instance()->get("output") == "html") { + header("Content-type: text/html"); + $html = preg_replace( + "#([\w]+?://[\w]+[^ \'\"\n\r\t<]*)#ise", "'\\1'", + var_export(!empty($data) ? $data : t("Empty response"), 1)); + print "
$html
"; + } else { + header("Content-type: application/json"); + print json_encode($data); } } -- cgit v1.2.3