diff --git a/module/dev/control.php b/module/dev/control.php
index c37dafe1df..4ff132fee8 100644
--- a/module/dev/control.php
+++ b/module/dev/control.php
@@ -1,24 +1,55 @@
+ * @package
+ * @uses control
+ * @license LGPL
+ * @version $Id$
+ * @Link http://www.zentao.net
+ */
class dev extends control
{
- public function api()
+ /**
+ * Get API of system.
+ *
+ * @access public
+ * @return void
+ */
+ public function api($module = '')
{
- $this->view->tables = $this->dev->getTables();
- $this->view->tab = 'api';
- $this->view->position[] = html::a(inlink('api'), $this->lang->dev->common);
- $this->view->position[] = $this->lang->dev->api;
+ $this->view->title = $this->lang->dev->api;
+ $this->view->position[] = html::a(inlink('api'), $this->lang->dev->common);
+ $this->view->position[] = $this->lang->dev->api;
+
+ $this->view->tables = $this->dev->getTables();
+ $this->view->tab = 'api';
+ $this->view->selectedModule = $module;
+ $this->view->apis = $module ? $this->dev->getAPIs($module) : array();
+ $this->view->modules = $this->dev->getModules();
$this->display();
}
+ /**
+ * Get schema of database.
+ *
+ * @param string $table
+ * @access public
+ * @return void
+ */
public function db($table = '')
{
+ $this->view->title = $this->lang->dev->db;
+ $this->view->position[] = html::a(inlink('api'), $this->lang->dev->common);
+ $this->view->position[] = $this->lang->dev->db;
+
$this->view->tables = $this->dev->getTables();
$this->view->tab = 'db';
$this->view->selectedTable = $table;
$this->view->tab = 'db';
- $this->view->fields = $table ? $this->dev->descTable($table) : array();
- $this->view->position[] = html::a(inlink('api'), $this->lang->dev->common);
- $this->view->position[] = $this->lang->dev->db;
+ $this->view->fields = $table ? $this->dev->getFields($table) : array();
$this->display();
}
}
diff --git a/module/dev/lang/en.php b/module/dev/lang/en.php
index e69de29bb2..e39034ee80 100644
--- a/module/dev/lang/en.php
+++ b/module/dev/lang/en.php
@@ -0,0 +1,81 @@
+dev->common = 'Develop';
+$lang->dev->api = 'API';
+$lang->dev->db = 'Database';
+$lang->dev->editor = 'Editor';
+$lang->dev->dbList = 'Database';
+$lang->dev->moduleList = 'Module list';
+$lang->dev->params = 'Params';
+$lang->dev->type = 'Type';
+$lang->dev->desc = 'Desc';
+$lang->dev->noParams = 'No param';
+
+$lang->dev->fields = array();
+$lang->dev->fields['id'] = 'ID';
+$lang->dev->fields['name'] = 'Name';
+$lang->dev->fields['desc'] = 'Desc';
+$lang->dev->fields['type'] = 'Type';
+$lang->dev->fields['length'] = 'Length';
+$lang->dev->fields['null'] = 'Null';
+
+$lang->dev->tableList = array();
+$lang->dev->tableList['action'] = 'Action';
+$lang->dev->tableList['bug'] = 'Bug';
+$lang->dev->tableList['build'] = 'Build';
+$lang->dev->tableList['burn'] = 'Burn';
+$lang->dev->tableList['case'] = 'Testcase';
+$lang->dev->tableList['casestep'] = 'Case step';
+$lang->dev->tableList['company'] = 'Company';
+$lang->dev->tableList['config'] = 'Config';
+$lang->dev->tableList['custom'] = 'Custom';
+$lang->dev->tableList['dept'] = 'Dept';
+$lang->dev->tableList['doc'] = 'Doc';
+$lang->dev->tableList['doclib'] = 'Doclib';
+$lang->dev->tableList['effort'] = 'Effort';
+$lang->dev->tableList['extension'] = 'Extension';
+$lang->dev->tableList['file'] = 'File';
+$lang->dev->tableList['group'] = 'Group';
+$lang->dev->tableList['grouppriv'] = 'Group priv';
+$lang->dev->tableList['history'] = 'History';
+$lang->dev->tableList['lang'] = 'Language';
+$lang->dev->tableList['module'] = 'Module';
+$lang->dev->tableList['product'] = 'Product';
+$lang->dev->tableList['productplan'] = 'Product plan';
+$lang->dev->tableList['project'] = 'Project';
+$lang->dev->tableList['projectproduct'] = 'Project product';
+$lang->dev->tableList['projectstory'] = 'Project story';
+$lang->dev->tableList['release'] = 'Release';
+$lang->dev->tableList['story'] = 'Story';
+$lang->dev->tableList['storyspec'] = 'Story spec';
+$lang->dev->tableList['task'] = 'Task';
+$lang->dev->tableList['taskestimate'] = 'Task estimate';
+$lang->dev->tableList['team'] = 'Team';
+$lang->dev->tableList['testresult'] = 'Test result';
+$lang->dev->tableList['testrun'] = 'Testrun';
+$lang->dev->tableList['testtask'] = 'Testtask';
+$lang->dev->tableList['todo'] = 'Todo';
+$lang->dev->tableList['user'] = 'User';
+$lang->dev->tableList['usercontact'] = 'User contact';
+$lang->dev->tableList['usergroup'] = 'User group';
+$lang->dev->tableList['userquery'] = 'User query';
+$lang->dev->tableList['usertpl'] = 'User template';
+$lang->dev->tableList['admin'] = 'Admin';
+$lang->dev->tableList['api'] = 'API';
+$lang->dev->tableList['backup'] = 'Backup';
+$lang->dev->tableList['common'] = 'Common';
+$lang->dev->tableList['convert'] = 'Convert';
+$lang->dev->tableList['dev'] = 'Dev';
+$lang->dev->tableList['git'] = 'GIT';
+$lang->dev->tableList['index'] = 'Index';
+$lang->dev->tableList['install'] = 'Install';
+$lang->dev->tableList['mail'] = 'Mail';
+$lang->dev->tableList['misc'] = 'Misc';
+$lang->dev->tableList['my'] = 'My';
+$lang->dev->tableList['qa'] = 'QA';
+$lang->dev->tableList['report'] = 'Report';
+$lang->dev->tableList['search'] = 'Search';
+$lang->dev->tableList['sso'] = 'SSO';
+$lang->dev->tableList['svn'] = 'SVN';
+$lang->dev->tableList['testcase'] = 'Testcase';
+$lang->dev->tableList['tree'] = 'Tree';
+$lang->dev->tableList['upgrade'] = 'Upgrade';
diff --git a/module/dev/lang/zh-cn.php b/module/dev/lang/zh-cn.php
index 81087e25af..ee34aa2ce0 100644
--- a/module/dev/lang/zh-cn.php
+++ b/module/dev/lang/zh-cn.php
@@ -1,9 +1,14 @@
dev->common = '二次开发';
-$lang->dev->api = 'API';
-$lang->dev->db = '数据库';
-$lang->dev->editor = '编辑器';
-$lang->dev->dbList = '数据库';
+$lang->dev->common = '二次开发';
+$lang->dev->api = 'API';
+$lang->dev->db = '数据库';
+$lang->dev->editor = '编辑器';
+$lang->dev->dbList = '数据库';
+$lang->dev->moduleList = '模块列表';
+$lang->dev->params = '参数列表';
+$lang->dev->type = '类型';
+$lang->dev->desc = '描述';
+$lang->dev->noParams = '无参数';
$lang->dev->fields = array();
$lang->dev->fields['id'] = '序号';
@@ -12,3 +17,65 @@ $lang->dev->fields['desc'] = '描述';
$lang->dev->fields['type'] = '类型';
$lang->dev->fields['length'] = '长度';
$lang->dev->fields['null'] = '是否可空';
+
+$lang->dev->tableList = array();
+$lang->dev->tableList['action'] = '操作记录';
+$lang->dev->tableList['bug'] = 'Bug';
+$lang->dev->tableList['build'] = '版本';
+$lang->dev->tableList['burn'] = '燃尽图';
+$lang->dev->tableList['case'] = '测试用例';
+$lang->dev->tableList['casestep'] = '用例步骤';
+$lang->dev->tableList['company'] = '公司';
+$lang->dev->tableList['config'] = '配置';
+$lang->dev->tableList['custom'] = '自定义';
+$lang->dev->tableList['dept'] = '部门';
+$lang->dev->tableList['doc'] = '文档';
+$lang->dev->tableList['doclib'] = '文档库';
+$lang->dev->tableList['effort'] = '日志';
+$lang->dev->tableList['extension'] = '插件';
+$lang->dev->tableList['file'] = '文件';
+$lang->dev->tableList['group'] = '用户组';
+$lang->dev->tableList['grouppriv'] = '组权限';
+$lang->dev->tableList['history'] = '操作历史';
+$lang->dev->tableList['lang'] = '语言定义';
+$lang->dev->tableList['module'] = '模块';
+$lang->dev->tableList['product'] = '产品';
+$lang->dev->tableList['productplan'] = '产品计划';
+$lang->dev->tableList['project'] = '项目';
+$lang->dev->tableList['projectproduct'] = '项目产品';
+$lang->dev->tableList['projectstory'] = '项目需求';
+$lang->dev->tableList['release'] = '发布';
+$lang->dev->tableList['story'] = '需求';
+$lang->dev->tableList['storyspec'] = '需求描述';
+$lang->dev->tableList['task'] = '任务';
+$lang->dev->tableList['taskestimate'] = '任务预计';
+$lang->dev->tableList['team'] = '团队';
+$lang->dev->tableList['testresult'] = '测试结果';
+$lang->dev->tableList['testrun'] = '测试执行';
+$lang->dev->tableList['testtask'] = '测试任务';
+$lang->dev->tableList['todo'] = '待办';
+$lang->dev->tableList['user'] = '用户';
+$lang->dev->tableList['usercontact'] = '用户联系人';
+$lang->dev->tableList['usergroup'] = '用户组';
+$lang->dev->tableList['userquery'] = '用户查询';
+$lang->dev->tableList['usertpl'] = '用户模板';
+$lang->dev->tableList['admin'] = '后台';
+$lang->dev->tableList['api'] = 'API';
+$lang->dev->tableList['backup'] = '备份';
+$lang->dev->tableList['common'] = '通用';
+$lang->dev->tableList['convert'] = '导入';
+$lang->dev->tableList['dev'] = '二次开发';
+$lang->dev->tableList['git'] = 'GIT';
+$lang->dev->tableList['index'] = '首页';
+$lang->dev->tableList['install'] = '安装';
+$lang->dev->tableList['mail'] = '邮箱';
+$lang->dev->tableList['misc'] = '杂项';
+$lang->dev->tableList['my'] = '我的地盘';
+$lang->dev->tableList['qa'] = '测试';
+$lang->dev->tableList['report'] = '统计';
+$lang->dev->tableList['search'] = '搜索';
+$lang->dev->tableList['sso'] = '单点登录';
+$lang->dev->tableList['svn'] = 'SVN';
+$lang->dev->tableList['testcase'] = '测试用例';
+$lang->dev->tableList['tree'] = '模块关系';
+$lang->dev->tableList['upgrade'] = '更新';
diff --git a/module/dev/model.php b/module/dev/model.php
index 1bbeb1cb90..fe84e4e04e 100644
--- a/module/dev/model.php
+++ b/module/dev/model.php
@@ -1,6 +1,12 @@
dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
@@ -14,7 +20,14 @@ class devModel extends model
return $tables;
}
- public function descTable($table)
+ /**
+ * Get fields of table.
+ *
+ * @param string $table
+ * @access public
+ * @return void
+ */
+ public function getFields($table)
{
$module = substr($table, strpos($table, '_') + 1);
try
@@ -98,4 +111,132 @@ class devModel extends model
}
return $fields;
}
+
+ /**
+ * Get APIs of a module.
+ *
+ * @param string $module
+ * @access public
+ * @return void
+ */
+ public function getAPIs($module)
+ {
+ $fileName = $this->app->getModuleRoot() . $module . $this->app->getPathFix() . 'control.php';
+ if($module != 'common' and $module != 'dev')
+ {
+ include $fileName;
+ }
+ $classReflect = new ReflectionClass($module);
+ $methods = $classReflect->getMethods();
+ $apis = array();
+ foreach($methods as $method)
+ {
+ if($method->class == 'control' or $method->name == '__construct') continue;
+
+ $api = array('name' => $method->name, 'post' => false, 'default' => array());
+ $methodReflect = new ReflectionMethod($module, $method->name);
+ foreach($methodReflect->getParameters() as $key => $param)
+ {
+ if($param->isOptional())
+ {
+ $api['default'][$param->getName()] = $param->getDefaultValue();
+ }
+ }
+ $startLine = $methodReflect->getStartLine();
+ $endLine = $methodReflect->getEndLine();
+ $comment = $methodReflect->getDocComment();
+
+ $file = file($fileName);
+ for($i = $startLine - 1; $i <= $endLine; $i++)
+ {
+ if(strpos($file[$i], '$this->post') or strpos($file[$i], 'fixer::input') or strpos($file[$i], '$_POST'))
+ {
+ $api['post'] = true;
+ }
+ }
+
+ // Strip the opening and closing tags of the docblock.
+ $comment = substr($comment, 3, -2);
+
+ // Split into arrays of lines.
+ $comment = preg_split('/\r?\n\r?/', $comment);
+
+ // Trim asterisks and whitespace from the beginning and whitespace from the end of lines.
+ $comment = array_map(function($line)
+ {
+ return ltrim(rtrim($line), "* \t\n\r\0\x0B");
+ }, $comment);
+
+ // Group the lines together by @tags
+ $blocks = array();
+ $b = -1;
+ foreach ($comment as $line)
+ {
+ if (isset($line[1]) && $line[0] == '@' && ctype_alpha($line[1]))
+ {
+ $b++;
+ $blocks[] = array();
+ } else if($b == -1) {
+ $b = 0;
+ $blocks[] = array();
+ }
+ $blocks[$b][] = $line;
+ }
+
+ // Parse the blocks
+ foreach ($blocks as $block => $body)
+ {
+ $body = trim(implode("\n", $body));
+ if($block == 0 && !(isset($body[1]) && $body[0] == '@' && ctype_alpha($body[1])))
+ {
+ // This is the description block
+ $api['desc'] = $body;
+ continue;
+ }
+ else
+ {
+ // This block is tagged
+ if(preg_match('/^@[a-z0-9_]+/', $body, $matches))
+ {
+ $tag = substr($matches[0], 1);
+ $body = substr($body, strlen($tag)+2);
+ if($tag == 'param')
+ {
+ $parts = preg_split('/\s+/', trim($body), 3);
+ $parts = array_pad($parts, 3, null);
+ $property = array('type', 'var', 'desc');
+ $param = array_combine($property, $parts);
+ $param['var'] = substr($param['var'], 1);
+ $api['param'][] = $param;
+ }
+ else
+ {
+ $api[$tag][] = $body;
+ }
+ }
+ }
+ }
+ $apis[] = $api;
+ }
+ return $apis;
+ }
+
+ /**
+ * Get all modules.
+ *
+ * @access public
+ * @return void
+ */
+ public function getModules()
+ {
+ $moduleList = glob($this->app->getModuleRoot() . '*');
+ $modules = array();
+ foreach($moduleList as $module)
+ {
+ $module = basename($module);
+ if($module == 'editor' or $module == 'help' or $module == 'setting') continue;
+ $modules[] = $module;
+ }
+ return $modules;
+ }
}
diff --git a/module/dev/view/api.html.php b/module/dev/view/api.html.php
index b8b4163544..b19c3faa60 100644
--- a/module/dev/view/api.html.php
+++ b/module/dev/view/api.html.php
@@ -1 +1,62 @@
+
+
+
dev->moduleList?>
+
+ dev->tableList[$module]) ? $lang->dev->tableList[$module] : $module;
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ createLink($selectedModule, $api['name'], $params);
+ ?>
+ |
+
+ |
+
+ | dev->params?> |
+ dev->type?> |
+ dev->desc?> |
+
+
+
+
+ |
+ |
+ |
+
+
+
+ | dev->noParams?> |
+
+
+
+
+
+
+
+
diff --git a/module/dev/view/db.html.php b/module/dev/view/db.html.php
index e3f9f040c2..f5183541e9 100644
--- a/module/dev/view/db.html.php
+++ b/module/dev/view/db.html.php
@@ -3,14 +3,18 @@
dev->dbList?>
-
-
+ dev->tableList[$subTable]) ? $lang->dev->tableList[$subTable] : $table;
+ ?>
+