* API: result data generation cleanup, minor cleaning
[lhc/web/wiklou.git] / includes / api / ApiMain.php
index 2f2c12a..f831fb5 100644 (file)
@@ -26,7 +26,7 @@
 \r
 if (!defined('MEDIAWIKI')) {\r
        // Eclipse helper - will be ignored in production\r
-       require_once ("ApiBase.php");\r
+       require_once ('ApiBase.php');\r
 }\r
 \r
 class ApiMain extends ApiBase {\r
@@ -50,7 +50,7 @@ class ApiMain extends ApiBase {
                $this->mResult = new ApiResult($this);\r
        }\r
 \r
-       public function getResult() {\r
+       public function getResult() {\r
                return $this->mResult;\r
        }\r
 \r
@@ -123,13 +123,16 @@ class ApiMain extends ApiBase {
 \r
        public function mainDieUsage($description, $errorCode, $httpRespCode = 0) {\r
                $this->mResult->Reset();\r
-               $this->mResult->addMessage('error', null, $errorCode);\r
                if ($httpRespCode === 0)\r
                        header($errorCode, true);\r
                else\r
                        header($errorCode, true, $httpRespCode);\r
 \r
-               $this->mResult->addMessage('usage', null, $this->makeHelpMsg());\r
+               $data = array (\r
+                       'code' => $errorCode\r
+               );\r
+               ApiResult :: addContent($data, $this->makeHelpMsg());\r
+               $this->mResult->addValue(null, 'error', $data);\r
 \r
                throw new UsageException($description, $errorCode);\r
        }\r
@@ -191,5 +194,4 @@ class UsageException extends Exception {
                return "{$this->codestr}: {$this->message}";\r
        }\r
 }\r
-\r
 ?>
\ No newline at end of file