}
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();