diff --git a/module/api/control.php b/module/api/control.php
index ffaa4674e2..3108871640 100644
--- a/module/api/control.php
+++ b/module/api/control.php
@@ -48,11 +48,19 @@ class api extends control
die($this->output);
}
+ /**
+ * The interface of api.
+ *
+ * @param int $filePath
+ * @param int $action
+ * @access public
+ * @return void
+ */
public function view($filePath, $action)
{
if($filePath)
{
- $host = common::getSysURL() . $this->config->webRoot;
+ $host = common::getSysURL() . $this->config->webRoot;
$filePath = helper::safe64Decode($filePath);
if($action == 'extendModel')
{
@@ -66,21 +74,40 @@ class api extends control
if(!empty($_POST))
{
$param = '';
- foreach($_POST as $key => $value) $param .= '&' . $key . '=' . $value;
- $param = trim($param, '&') . "&{$this->config->sessionVar}=" . session_id();
- $url = rtrim($host, '/') . $this->createLink($method->className, $method->methodName, $param, 'json');
+ if($action == 'extendModel')
+ {
+ foreach($_POST as $key => $value) $param .= ',' . $key . '=' . $value;
+ $param = ltrim($param, ',');
+ $url = rtrim($host, '/') . inlink('getModel', "moduleName={$method->className}&methodName={$method->methodName}¶ms=$param", 'json');
+ $url .= $this->config->requestType == "PATH_INFO" ? '?' : '&';
+ $url .= $this->config->sessionVar . '=' . session_id();
+ }
+ else
+ {
+ foreach($_POST as $key => $value) $param .= '&' . $key . '=' . $value;
+ $param = ltrim($param, '&');
+ $url = rtrim($host, '/') . $this->createLink($method->className, $method->methodName, $param, 'json');
+ $url .= $this->config->requestType == "PATH_INFO" ? '?' : '&';
+ $url .= $this->config->sessionVar . '=' . session_id();
+ }
+
+ /* Unlock session. After new request, restart session. */
+ session_write_close();
$content = file_get_contents($url);
+ session_start();
+
$result = json_decode($content);
$status = $result->status;
$data = json_decode($result->data);
$data = '
' . print_r($data, true) . '';
$response['result'] = 'success';
- $response['status'] = $status;
- $response['url'] = $url;
- $response['data'] = $data;
+ $response['status'] = $status;
+ $response['url'] = $url;
+ $response['data'] = $data;
$this->send($response);
}
+
$this->view->method = $method;
$this->view->filePath = $filePath;
$this->display();
diff --git a/module/api/lang/en.php b/module/api/lang/en.php
index 14af76dfb4..feb159dd16 100644
--- a/module/api/lang/en.php
+++ b/module/api/lang/en.php
@@ -16,7 +16,7 @@ $lang->api->getModel = 'Super Model API';
$lang->api->position = 'Position';
$lang->api->startLine = "%s, line %s";
$lang->api->desc = 'Desc';
-$lang->api->test = 'Test';
+$lang->api->debug = 'Debug';
$lang->api->noParam = 'No params in this method';
$lang->api->submit = 'submit';
$lang->api->url = 'Request url';
diff --git a/module/api/lang/zh-cn.php b/module/api/lang/zh-cn.php
index 2169e670e6..0210bfcafa 100644
--- a/module/api/lang/zh-cn.php
+++ b/module/api/lang/zh-cn.php
@@ -16,7 +16,7 @@ $lang->api->getModel = '超级model调用接口';
$lang->api->position = '位置';
$lang->api->startLine = "%s,%s行";
$lang->api->desc = '描述';
-$lang->api->test = '测试';
+$lang->api->debug = '调试';
$lang->api->noParam = '该方法没有参数';
$lang->api->submit = '提交';
$lang->api->url = '请求地址';
diff --git a/module/api/model.php b/module/api/model.php
index 25e69c3ddb..61920b126c 100644
--- a/module/api/model.php
+++ b/module/api/model.php
@@ -21,11 +21,22 @@ class apiModel extends model
$method = new ReflectionMethod($className . $ext, $methodName);
$data = new stdClass();
$data->startLine = $method->getStartLine();
+ $data->endLine = $method->getEndLine();
$data->comment = $method->getDocComment();
$data->parameters = $method->getParameters();
$data->className = $className;
$data->methodName = $methodName;
$data->fileName = $fileName;
+ $data->post = false;
+
+ $file = file($fileName);
+ for($i = $data->startLine - 1; $i <= $data->endLine; $i++)
+ {
+ if(strpos($file[$i], '$this->post') or strpos($file[$i], 'fixer::input') or strpos($file[$i], '$_POST'))
+ {
+ $data->post = true;
+ }
+ }
return $data;
}
}
diff --git a/module/api/view/view.html.php b/module/api/view/view.html.php
index 61225f5390..a2e18c804d 100644
--- a/module/api/view/view.html.php
+++ b/module/api/view/view.html.php
@@ -2,7 +2,7 @@
-
+ post ? 'GET/POST ' . $filePath : 'GET ' . $filePath?>
|
@@ -18,7 +18,7 @@
|
|
- {$lang->api->test}"?>
+ {$lang->api->debug}"?>
parameters):?>
|