diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2007-09-14 13:18:58 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2007-09-14 13:18:58 +0200 |
commit | 8f416baead93a48e5799e44b8bd2e2c4859f4e04 (patch) | |
tree | cd47ac55eb80a39e3225e8b4f3161b88ea16c2cf /includes/api/ApiFormatJson.php | |
parent | d7d08bd1a17618c7d77a6b9b2989e9f7293d6ed6 (diff) |
auf Version 1.11 aktualisiert; Login-Bug behoben
Diffstat (limited to 'includes/api/ApiFormatJson.php')
-rw-r--r-- | includes/api/ApiFormatJson.php | 31 |
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 $'; } } -?> + |