summaryrefslogtreecommitdiff
path: root/includes/api/ApiFormatJson.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiFormatJson.php')
-rw-r--r--includes/api/ApiFormatJson.php31
1 files changed, 26 insertions, 5 deletions
diff --git a/includes/api/ApiFormatJson.php b/includes/api/ApiFormatJson.php
index dd1847c4..ed9bd938 100644
--- a/includes/api/ApiFormatJson.php
+++ b/includes/api/ApiFormatJson.php
@@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
- * Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
+ * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -49,14 +49,35 @@ class ApiFormatJson extends ApiFormatBase {
}
public function execute() {
+ $prefix = $suffix = "";
+
+ $params = $this->extractRequestParams();
+ $callback = $params['callback'];
+ if(!is_null($callback)) {
+ $prefix = ereg_replace("[^_A-Za-z0-9]", "", $callback ) . "(";
+ $suffix = ")";
+ }
+
if (!function_exists('json_encode') || $this->getIsHtml()) {
$json = new Services_JSON();
- $this->printText($json->encode($this->getResultData(), $this->getIsHtml()));
+ $this->printText($prefix . $json->encode($this->getResultData(), $this->getIsHtml()) . $suffix);
} else {
- $this->printText(json_encode($this->getResultData()));
+ $this->printText($prefix . json_encode($this->getResultData()) . $suffix);
}
}
+ protected function getAllowedParams() {
+ return array (
+ 'callback' => null
+ );
+ }
+
+ protected function getParamDescription() {
+ return array (
+ 'callback' => 'If specified, wraps the output into a given function call',
+ );
+ }
+
protected function getDescription() {
if ($this->mIsRaw)
return 'Output data with the debuging elements in JSON format' . parent :: getDescription();
@@ -65,7 +86,7 @@ class ApiFormatJson extends ApiFormatBase {
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiFormatJson.php 21402 2007-04-20 08:55:14Z nickj $';
+ return __CLASS__ . ': $Id: ApiFormatJson.php 23531 2007-06-29 01:19:14Z simetrical $';
}
}
-?>
+