diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2010-02-14 07:31:11 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2010-02-14 07:31:11 -0800 |
commit | f37b93a7eb34c766d2d741064a611afd1760c959 (patch) | |
tree | fa4419ea94b9bc43582505899c83a370d2f3f8b3 | |
parent | 378c7fb45a07601945f1e8f369f1cba68866556b (diff) |
If the return object is empty still return the empty object in the json response.
-rw-r--r-- | modules/rest/helpers/rest.php | 20 |
1 files changed, 9 insertions, 11 deletions
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", "'<a href=\"\\1\" >\\1</a>'", - var_export($data, 1)); - print "<pre>$html</pre>"; - } 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", "'<a href=\"\\1\" >\\1</a>'", + var_export(!empty($data) ? $data : t("Empty response"), 1)); + print "<pre>$html</pre>"; + } else { + header("Content-type: application/json"); + print json_encode($data); } } |