summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/format.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/format.php b/lib/format.php
index 25748f0..f0f34b3 100644
--- a/lib/format.php
+++ b/lib/format.php
@@ -6,19 +6,19 @@ if (function_exists("export_as_requested"))
include_once BASE . "/lib/http.php";
-function export_as_requested($content) {
+function export_as_requested($content, $format = NULL) {
if (isset($content["All"])) {
$content["json"]=$content["All"];
$content["tsv"]=$content["All"];
unset($content["All"]);
}
- if (isset($content["json"]) && array_key_exists("json", $_GET)) {
+ if (isset($content["json"]) && ((empty($format) && array_key_exists("json", $_GET)) || ($format == 'json'))) {
header ("Content-type: application/json");
print json_encode(
$content["json"],
JSON_UNESCAPED_SLASHES
);
- } elseif (isset($content["tsv"]) && array_key_exists("tsv", $_GET)) {
+ } elseif (isset($content["tsv"]) && ((empty($format) && array_key_exists("tsv", $_GET)) || ($format == 'tsv'))) {
header ("Content-type: text/tab-separated-values");
if (! array_key_exists("no-headers", $_GET))
print implode("\t",array_keys($content["tsv"][0])) . "\n";
@@ -32,6 +32,8 @@ function export_as_requested($content) {
)
);
} else {
+ if (!empty($format))
+ return false;
throw_http_error(
406,
"Not Acceptable",
@@ -54,4 +56,5 @@ function export_as_requested($content) {
)
);
}
+ return true;
}