From e1bed5bc55155dc136c9288a92cb64432f40f8a0 Mon Sep 17 00:00:00 2001 From: xiawenlong Date: Mon, 18 Oct 2021 16:13:46 +0800 Subject: [PATCH] finish api release. --- db/update15.5.sql | 18 ++--- module/api/config.php | 17 ++--- module/api/control.php | 120 +++++++++++++++++++++++++------ module/api/js/common.js | 4 +- module/api/js/editstruct.js | 2 +- module/api/lang/zh-cn.php | 35 ++++++--- module/api/model.php | 112 +++++++++++++++++++++++++---- module/api/view/content.html.php | 23 +++--- module/api/view/create.html.php | 8 +-- module/api/view/index.html.php | 111 +++++++++++++++------------- module/doc/model.php | 70 +++++++++++------- module/group/lang/resource.php | 30 ++++++++ module/task/lang/zh-cn.php | 4 +- 13 files changed, 401 insertions(+), 153 deletions(-) diff --git a/db/update15.5.sql b/db/update15.5.sql index d370f15255..6eacf25fd1 100644 --- a/db/update15.5.sql +++ b/db/update15.5.sql @@ -58,7 +58,7 @@ CREATE TABLE `zt_apispec` `method` varchar(10) NOT NULL DEFAULT '', `requestType` varchar(100) NOT NULL DEFAULT '', `responseType` varchar(100) NOT NULL DEFAULT '', - `status` tinyint UNSIGNED NOT NULL DEFAULT 0, + `status` varchar(20) NOT NULL DEFAULT '', `owner` varchar(255) NOT NULl DEFAULT 0, `desc` text NULL, `version` smallint UNSIGNED NOT NULL DEFAULT 0, @@ -90,13 +90,13 @@ create table `zt_apistruct` -- DROP TABLE IF EXISTS `zt_apistruct_spec`; create table `zt_apistruct_spec` ( - `id` int UNSIGNED NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL DEFAULT '', - `type` varchar(50) NOT NULL DEFAULT '', - `desc` varchar(255) NOT NULL DEFAULT '', - `attribute` text NULL, - `version` smallint unsigned NOT NULL DEFAULT 0, - `addedBy` varchar(30) NOT NULL DEFAULT 0, - `addedDate` datetime NOT NULL, + `id` int UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL DEFAULT '', + `type` varchar(50) NOT NULL DEFAULT '', + `desc` varchar(255) NOT NULL DEFAULT '', + `attribute` text NULL, + `version` smallint unsigned NOT NULL DEFAULT 0, + `addedBy` varchar(30) NOT NULL DEFAULT 0, + `addedDate` datetime NOT NULL, primary key (`id`) ) diff --git a/module/api/config.php b/module/api/config.php index 93e7e24660..ab48a047d3 100644 --- a/module/api/config.php +++ b/module/api/config.php @@ -1,25 +1,26 @@ api = new stdClass(); -$config->api->createlib = new stdclass(); +$config->api = new stdClass(); +$config->api->createlib = new stdclass(); $config->api->createlib->requiredFields = 'name'; -$config->api->editlib = new stdclass(); +$config->api->editlib = new stdclass(); $config->api->editlib->requiredFields = 'name'; -$config->api->struct = new stdClass(); +$config->api->struct = new stdClass(); $config->api->struct->requiredFields = 'name,params'; -$config->api->create = new stdclass(); +$config->api->create = new stdclass(); $config->api->create->requiredFields = 'lib,title,path'; -$config->api->edit = new stdclass(); +$config->api->edit = new stdclass(); $config->api->edit->requiredFields = 'lib,title,path'; -$config->api->publish = new stdclass(); +$config->api->publish = new stdclass(); $config->api->publish->requiredFields = 'version'; -$config->api->editor = new stdclass(); +$config->api->editor = new stdclass(); $config->api->editor->createlib = array('id' => 'desc', 'tools' => 'simpleTools'); +$config->api->editor->editlib = array('id' => 'desc', 'tools' => 'simpleTools'); $config->api->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); $config->api->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); $config->api->editor->publish = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/api/control.php b/module/api/control.php index cc74e5d890..37f0e15a82 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -26,10 +26,12 @@ class api extends control * @param int $libID * @param int $moduleID * @param int $apiID + * @param int $version + * @param int $release * @access public * @return void */ - public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0) + public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0, $release = 0) { /* Get all api doc libraries. */ $libs = $this->doc->getApiLibs(); @@ -38,7 +40,7 @@ class api extends control if($libs) { if($libID == 0) $libID = key($libs); - $this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID); + $this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID, $release); } $this->setMenu($libID); @@ -61,11 +63,13 @@ class api extends control else { /* Get module api list. */ - $apiList = $this->api->getListByModuleId($libID, $moduleID); + $apiList = $this->api->getListByModuleId($libID, $moduleID, $release); $this->view->apiList = $apiList; } + $this->view->isRelease = $release > 0; + $this->view->release = $release; $this->view->title = $this->lang->api->title; $this->view->libID = $libID; $this->view->apiID = $apiID; @@ -87,8 +91,9 @@ class api extends control { $lib = $this->doc->getLibById($libID); - if(!empty($_POST)) { - $data = fixer::input('post') + if(!empty($_POST)) + { + $data = fixer::input('post') ->add('lib', $libID) ->add('addedBy', $this->app->user->account) ->add('addedDate', helper::now()) @@ -120,7 +125,10 @@ class api extends control */ public function struct($libID = 0, $orderBy = 'id', $recTotal = 0, $recPerPage = 15, $pageID = 1) { + $libs = $this->doc->getApiLibs(); $this->app->loadClass('pager', $static = true); + $this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID); + $pager = new pager($recTotal, $recPerPage, $pageID); /* Append id for secend sort. */ @@ -299,10 +307,7 @@ class api extends control $doc = $this->doc->getLibById($id); if(!empty($_POST)) { - $lib = fixer::input('post') - ->join('groups', ',') - ->join('users', ',') - ->get(); + $lib = fixer::input('post')->join('groups', ',')->join('users', ',')->get(); if($lib->acl == 'private') $lib->users = $this->app->user->account; $this->doc->updateApiLib($id, $doc, $lib); @@ -324,6 +329,31 @@ class api extends control $this->display(); } + + /** + * @param int $libID + * @param string $confirm + * @param string $from + */ + public function deleteLib($libID, $confirm = 'no') + { + if($confirm == 'no') + { + die(js::confirm($this->lang->doc->confirmDeleteLib, $this->createLink('api', 'deleteLib', "libID=$libID&confirm=yes"))); + } + else + { + $this->doc->delete(TABLE_DOCLIB, $libID); + if(isonlybody()) + { + unset($_GET['onlybody']); + die(js::locate($this->createLink('api', 'index'), 'parent.parent')); + } + + die(js::locate($this->createLink('api', 'index'), 'parent')); + } + } + /** * Edit library. * @@ -429,15 +459,7 @@ class api extends control $example = array('example' => 'type,description'); $example = json_encode($example, JSON_PRETTY_PRINT); - $options = []; - foreach($this->lang->api->paramsTypeOptions as $key => $item) - { - $options[] = [ - 'label' => $item, - 'value' => $key, - ]; - } - $this->view->typeOptions = $options; + $this->getTypeOptions($libID); $this->view->user = $this->app->user->account; $this->view->allUsers = $this->loadModel('user')->getPairs('devfirst|noclosed'); $this->view->libID = $libID; @@ -549,7 +571,10 @@ class api extends control // global struct link $menu = ''; - $menu .= html::a(helper::createLink('api', 'publish', "libID=$libID"), $this->lang->api->publish, '', 'class="btn btn-link iframe"'); + if(common::hasPriv('api', 'publish')) + { + $menu .= html::a(helper::createLink('api', 'publish', "libID=$libID"), $this->lang->api->publish, '', 'class="btn btn-link iframe"'); + } // page of index menu if(intval($libID) > 0) { @@ -591,10 +616,11 @@ class api extends control * * @param array $libs * @param int $libID + * @param int $version * @access public * @return string */ - private function generateLibsDropMenu($libs, $libID) + private function generateLibsDropMenu($libs, $libID, $version = 0) { if(empty($libs)) return ''; @@ -620,6 +646,35 @@ EOT; } $output .= ""; + /* Get lib version */ + $versions = $this->api->getReleaseListByApi($libID); + if(!empty($versions)) + { + $versionName = $version > 0 ? $versions[$version]->desc : $this->lang->api->defaultVersion; + $output .= << +
+ +
"; + } + return $output; } @@ -642,8 +697,7 @@ EOT; * @access public * @return void */ - public - function getSessionID() + public function getSessionID() { $this->session->set('rand', mt_rand(0, 10000)); $this->view->sessionName = session_name(); @@ -745,4 +799,26 @@ EOT; die($this->output); } + private function getTypeOptions($libID) + { + $options = []; + foreach($this->lang->api->paramsTypeOptions as $key => $item) + { + $options[] = [ + 'label' => $item, + 'value' => $key, + ]; + } + /* get all struct by libID. */ + $structs = $this->api->getStructListByLibID($libID); + foreach($structs as $struct) + { + $options[] = [ + 'label' => $struct->name, + 'value' => $struct->id, + ]; + } + $this->view->typeOptions = $options; + } + } diff --git a/module/api/js/common.js b/module/api/js/common.js index 3cf12a923c..39ea04a053 100644 --- a/module/api/js/common.js +++ b/module/api/js/common.js @@ -235,7 +235,7 @@ try { - + @@ -400,7 +400,7 @@ try { ${struct_field} ${struct_paramsType} ${struct_required} - ${struct_desc} + ${struct_desc} ${struct_action} diff --git a/module/api/js/editstruct.js b/module/api/js/editstruct.js index 87705ecba6..c695defea9 100644 --- a/module/api/js/editstruct.js +++ b/module/api/js/editstruct.js @@ -6,7 +6,7 @@ new Vue({ attr: '', struct: { ...struct, - attribute: JSON.parse(struct.attribute) + attribute: struct.attribute } } }, diff --git a/module/api/lang/zh-cn.php b/module/api/lang/zh-cn.php index ba4ad29fa1..28d2b144cd 100755 --- a/module/api/lang/zh-cn.php +++ b/module/api/lang/zh-cn.php @@ -14,7 +14,28 @@ $lang->api->common = 'API接口'; $lang->api->getModel = '超级model调用接口'; $lang->api->sql = 'SQL查询接口'; -$lang->api->publish = '发布'; +/* function of api doc */ +$lang->apiDoc = new stdClass(); +$lang->apiDoc->common = '接口库'; +$lang->apiDoc->index = '接口库主页'; +$lang->apiDoc->createLib = '创建接口库'; +$lang->apiDoc->editLib = '编辑接口库'; +$lang->apiDoc->deleteLib = '删除接口库'; +$lang->apiDoc->publish = '发布接口'; +$lang->apiDoc->structPage = '数据结构'; +$lang->apiDoc->createStruct = '创建数据结构'; +$lang->apiDoc->editStruct = '创建数据结构'; +$lang->apiDoc->deleteStruct = '删除数据结构'; +$lang->apiDoc->createApi = '创建接口'; +$lang->apiDoc->editApi = '编辑接口'; +$lang->apiDoc->deleteApi = '删除接口'; + +$lang->api->editLib = '编辑接口库'; +$lang->api->deleteLib = '删除接口库'; +$lang->api->createStruct = '创建数据结构'; +$lang->api->publish = '发布接口'; +$lang->api->createLib = '创建接口库'; +$lang->api->createApi = '创建接口'; $lang->api->edit = '编辑'; $lang->api->delete = '删除'; $lang->api->position = '位置'; @@ -32,17 +53,12 @@ $lang->api->post = 'POST方式调试请参照页面表单'; $lang->api->noUniqueName = '接口库名已存在。'; $lang->api->noUniqueVersion = '版本已存在。'; $lang->api->version = '版本'; -$lang->api->createLib = '创建接口库'; -$lang->api->createStruct = '创建数据结构'; $lang->api->editStruct = '修改数据结构'; -$lang->api->editLib = '编辑接口库'; -$lang->api->deleteLib = '删除接口库'; $lang->api->create = '创建文档'; -$lang->api->createApi = '创建接口'; $lang->api->title = '接口库'; -$lang->api->module = '模块'; +$lang->api->module = '目录'; $lang->api->apiDoc = '接口'; -$lang->api->manageType = '维护模块'; +$lang->api->manageType = '维护目录'; $lang->api->doing = '开发中'; $lang->api->done = '开发完成'; $lang->api->basicInfo = '基本信息'; @@ -50,6 +66,7 @@ $lang->api->apiDesc = '接口说明'; $lang->api->confirmDelete = "您确定删除该接口吗?"; $lang->api->confirmDeleteLib = "您确定删除该接口库吗?"; $lang->api->filterStruct = "使用数据结构填充"; +$lang->api->defaultVersion = "当前版本"; /* fields of struct */ $lang->struct = new stdClass(); @@ -84,7 +101,7 @@ $lang->api->control = '访问控制'; $lang->api->noLib = '暂时没有接口库。'; $lang->api->noApi = '暂时没有接口。'; $lang->api->lib = '所属接口库'; -$lang->api->module = '所属模块'; +$lang->api->apiList = '接口列表'; $lang->api->formTitle = '接口名称'; $lang->api->path = '请求路径'; $lang->api->protocol = '请求协议'; diff --git a/module/api/model.php b/module/api/model.php index 08ce11a835..f7c4cf84e3 100644 --- a/module/api/model.php +++ b/module/api/model.php @@ -95,7 +95,12 @@ class apiModel extends model ->batchCheck($this->config->api->create->requiredFields, 'notempty') ->exec(); - return dao::isError() ? false : $this->dao->lastInsertID(); + $id = $this->dao->lastInsertID(); + + $apiSpec = $this->getApiSpecByData($params); + $this->dao->replace(TABLE_API_SPEC)->data($apiSpec)->exec(); + + return dao::isError() ? false : $id; } /** @@ -113,6 +118,8 @@ class apiModel extends model ->batchCheck($this->config->api->struct->requiredFields, 'notempty') ->exec(); + $id = $this->dao->lastInsertID(); + /* Create a struct version. */ $version = array( 'name' => $data->name, @@ -125,7 +132,7 @@ class apiModel extends model ); $this->dao->insert(TABLE_APISTRUCT_SPEC)->data($version)->exec(); - return dao::isError() ? 0 : $this->dao->lastInsertID(); + return dao::isError() ? 0 : $id; } /** @@ -267,6 +274,38 @@ class apiModel extends model return $model; } + /** + * Get release by id. + * + * @param int $id + * @access public + * @return array + */ + public function getReleaseById($id) + { + $model = $this->dao->select('*') + ->from(TABLE_API_LIB_RELEASE) + ->where('id')->eq($id) + ->fetch(); + if($model) $model->snap = json_decode(htmlspecialchars_decode($model->snap), true); + return $model; + } + + /** + * Get Versions by api id + * + * @param int $libID + * @access public + * @return array + */ + public function getReleaseListByApi($libID) + { + $versions = $this->dao->select('*')->from(TABLE_API_LIB_RELEASE) + ->where('lib')->eq($libID) + ->fetchAll('id'); + return $versions; + } + /** * Get api doc by id. @@ -305,30 +344,79 @@ class apiModel extends model return $model; } + /** + * Get api list by release. + * + * @param object $release + * @param string $where + * @return array + */ + public function getApiListByRelease($release, $where = '') + { + $strJoin = array(); + foreach($release->snap['apis'] as $api) + { + $strJoin[] = "(doc = {$api['id']} and version = {$api['version']} )"; + } + + $where .= 'and (' . implode(' or ', $strJoin) . ')'; + $list = $this->dao->select('*')->from(TABLE_API_SPEC) + ->where($where) + ->fetchAll(); + return $list; + } + /** * Get api doc list by module id * * @param int $libID * @param int $moduleID + * @param int $release * @return array $list * @author thanatos thanatos915@163.com */ - public function getListByModuleId($libID = 0, $moduleID = 0) + public function getListByModuleId($libID = 0, $moduleID = 0, $release = 0) { - if($moduleID > 0) + /* Get release info. */ + if($release > 0) { - $sub = $this->dao->select('id')->from(TABLE_MODULE)->where('FIND_IN_SET(' . $moduleID . ', path)')->processSQL(); - $where = 'module in (' . $sub . ')'; + $rel = $this->getReleaseById($release); + + $where = '1=1 '; + if($moduleID > 0) + { + $sub = array(); + foreach($rel->snap['modules'] as $module) + { + $tmp = explode(',', $module['path']); + if(in_array($moduleID, $tmp)) + { + $sub[] = $module['id']; + } + } + $where .= 'and module in (' . implode(',', $sub) . ')'; + } + + $list = $this->getApiListByRelease($rel, $where); } else { - $where = 'lib = ' . $libID; + + if($moduleID > 0) + { + $sub = $this->dao->select('id')->from(TABLE_MODULE)->where('FIND_IN_SET(' . $moduleID . ', path)')->processSQL(); + $where = 'module in (' . $sub . ')'; + } + else + { + $where = 'lib = ' . $libID; + } + $list = $this->dao->select('*') + ->from(TABLE_API) + ->where($where) + ->andWhere('deleted')->eq(0) + ->fetchAll(); } - $list = $this->dao->select('*') - ->from(TABLE_API) - ->where($where) - ->andWhere('deleted')->eq(0) - ->fetchAll(); array_map(function ($item) { $item->params = json_decode(htmlspecialchars_decode($item->params), true); return $item; diff --git a/module/api/view/content.html.php b/module/api/view/content.html.php index 7506b0de5d..64267e4ce4 100644 --- a/module/api/view/content.html.php +++ b/module/api/view/content.html.php @@ -19,7 +19,7 @@ version; $version > 0; $version--):?>
  • '># + data-url='createLink('api', 'index', "libID={$api->lib}&moduleID=0&apiID=$apiID&version=$version&release=$release");?>'>#
  • @@ -29,13 +29,16 @@
    ', '', "title='{$lang->fullscreen}' class='btn btn-link fullscreen-btn'"); - if(common::hasPriv('api', 'edit')) echo html::a(inlink('edit', "apiID=$api->id"), '', '', "title='{$lang->api->edit}' class='btn btn-link' data-app='{$this->app->tab}'"); - if(common::hasPriv('doc', 'delete')) + if(!$isRelease) { - $deleteURL = $this->createLink('api', 'delete', "apiID=$api->id&confirm=yes"); - echo html::a("javascript:ajaxDeleteApi(\"$deleteURL\", confirmDelete)", '', '', "title='{$lang->api->delete}' class='btn btn-link'"); + if(common::hasPriv('api', 'edit')) echo html::a(inlink('edit', "apiID=$api->id"), '', '', "title='{$lang->api->edit}' class='btn btn-link' data-app='{$this->app->tab}'"); + if(common::hasPriv('api', 'delete')) + { + $deleteURL = $this->createLink('api', 'delete', "apiID=$api->id&confirm=yes"); + echo html::a("javascript:ajaxDeleteApi(\"$deleteURL\", confirmDelete)", '', '', "title='{$lang->api->delete}' class='btn btn-link'"); + } } - ;?> + ?>
    @@ -97,13 +100,13 @@ '; + $str = ''; $field = ''; - for($i=0; $i < $level; $i++) + for($i = 0; $i < $level; $i++) { - $field .= '   '; + $field .= '  ∟  '; } - $field .= $data['field']; + $field .= $data['field']; $str .= '' . $field . ''; $str .= '' . $data['paramsType'] . ''; $require = $data['required'] ? '是' : '否'; diff --git a/module/api/view/create.html.php b/module/api/view/create.html.php index 6be1e2c185..1ce4216407 100644 --- a/module/api/view/create.html.php +++ b/module/api/view/create.html.php @@ -122,7 +122,7 @@ js::set('struct_paramsType', $lang->struct->paramsType); struct->field;?> struct->required;?> - struct->desc;?> + struct->desc;?> struct->action;?> @@ -138,7 +138,7 @@ js::set('struct_paramsType', $lang->struct->paramsType); - + @@ -157,7 +157,7 @@ js::set('struct_paramsType', $lang->struct->paramsType); struct->field;?> struct->required;?> - struct->desc;?> + struct->desc;?> struct->action;?> @@ -173,7 +173,7 @@ js::set('struct_paramsType', $lang->struct->paramsType); - + diff --git a/module/api/view/index.html.php b/module/api/view/index.html.php index 846406b2fd..96bd7eb3f7 100644 --- a/module/api/view/index.html.php +++ b/module/api/view/index.html.php @@ -18,16 +18,25 @@
    - + "; - echo html::a('javascript:;', "", '', "data-toggle='dropdown' class='btn btn-link'"); - echo "
    '; + if(!$isRelease) + { + echo "'; + } ?>
    @@ -40,52 +49,54 @@ - + - -
    -
    -
  • 0 ? $lang->api->module : $lang->api->title; ?>
  • + +
    +
    +
  • 0 ? $lang->api->apiList : $lang->api->title; ?>
  • +
    +
    +
    -
    -
    -
    api->noLib : $lang->api->noApi; ?>
    -
    - ' . $lang->api->createApi, '', 'class="btn btn-info btn-wide"'); - } - else - { - $html = html::a(helper::createLink('api', 'createLib'), ' ' . $lang->api->createLib, '', 'class="btn btn-info btn-wide iframe"'); - } - echo $html; - ?> -
    +
    api->noLib : $lang->api->noApi; ?>
    +
    + ' . $lang->api->createApi, '', 'class="btn btn-info btn-wide"'); + } + else + { + $html = html::a(helper::createLink('api', 'createLib'), ' ' . $lang->api->createLib, '', 'class="btn btn-info btn-wide iframe"'); + } + echo $html; + ?>
    - - + + +
    diff --git a/module/doc/model.php b/module/doc/model.php index 7904b38eda..9a3902975f 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -86,7 +86,7 @@ class docModel extends model $executions = $this->loadModel('execution')->getPairs(); $libPairs = array(); - while($lib = $stmt->fetch()) + while ($lib = $stmt->fetch()) { if($lib->product != 0 and !isset($products[$lib->product])) continue; if($lib->execution != 0 and !isset($executions[$lib->execution])) continue; @@ -108,7 +108,7 @@ class docModel extends model if(!empty($appendLibs)) { $stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where('id')->in($appendLibs)->orderBy('`order`, id desc')->query(); - while($lib = $stmt->fetch()) + while ($lib = $stmt->fetch()) { if(!isset($libPairs[$lib->id]) and $this->checkPrivLib($lib, $extra)) $libPairs[$lib->id] = $lib->name; } @@ -133,7 +133,7 @@ class docModel extends model $account = ",{$this->app->user->account},"; $userGroups = $this->app->user->groups; - while($lib = $stmt->fetch()) + while ($lib = $stmt->fetch()) { if(strpos(",$lib->users,", $account) !== false) { @@ -219,9 +219,10 @@ class docModel extends model ->exec(); $changes = array(); - if(!dao::isError()) { + if(!dao::isError()) + { $this->loadModel('action'); - $changes = common::createChanges($oldDoc, $data); + $changes = common::createChanges($oldDoc, $data); $actionID = $this->action->create('docLib', $id, 'Edited'); $this->action->logHistory($actionID, $changes); } @@ -460,7 +461,7 @@ class docModel extends model ->query(); $docIdList = array(); - while($doc = $stmt->fetch()) + while ($doc = $stmt->fetch()) { if($this->checkPrivDoc($doc)) $docIdList[$doc->id] = $doc->id; } @@ -1037,7 +1038,7 @@ class docModel extends model $executionLibs = array(); $otherLibs = array(); - while($lib = $stmt->fetch()) + while ($lib = $stmt->fetch()) { if($lib->type == 'product') { @@ -2170,16 +2171,26 @@ EOT; * * @author thanatos thanatos915@163.com */ - public function getApiModuleTree($rootID, &$docID = 0) + public function getApiModuleTree($rootID, &$docID = 0, $release = 0) { $startModulePath = ''; $currentMethod = $this->app->getMethodName(); $users = $this->loadModel('user')->getPairs('noletter'); + $this->loadModel('api'); + + if($release) + { + $rel = $this->api->getReleaseById($release); + $docs = $this->api->getApiListByRelease($rel); + } + else + { + $docs = $this->dao->select('*')->from(TABLE_API) + ->where('lib')->eq($rootID) + ->andWhere('deleted')->eq(0) + ->fetchAll(); + } - $docs = $this->dao->select('*')->from(TABLE_API) - ->where('lib')->eq($rootID) - ->andWhere('deleted')->eq(0) - ->fetchAll(); $moduleDocs = array(); foreach($docs as $doc) { @@ -2189,18 +2200,29 @@ EOT; } $treeMenu = array(); - $query = $this->dao->select('*')->from(TABLE_MODULE) - ->where('root')->eq((int)$rootID) - ->andWhere('type')->eq('api') - ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() - ->andWhere('deleted')->eq(0) - ->orderBy('grade desc, `order`') - ->get(); - $stmt = $this->dbh->query($query); - while($module = $stmt->fetch()) + if($release) { - $this->buildTree($treeMenu, 'api', 0, $rootID, $module, $moduleDocs, $docID); + foreach($release->snap['modules'] as $module) + { + $this->buildTree($treeMenu, 'api', 0, $rootID, $module, $moduleDocs, $docID); + } } + else + { + $query = $this->dao->select('*')->from(TABLE_MODULE) + ->where('root')->eq((int)$rootID) + ->andWhere('type')->eq('api') + ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() + ->andWhere('deleted')->eq(0) + ->orderBy('grade desc, `order`') + ->get(); + $stmt = $this->dbh->query($query); + while ($module = $stmt->fetch()) + { + $this->buildTree($treeMenu, 'api', 0, $rootID, $module, $moduleDocs, $docID); + } + } + if(isset($moduleDocs[0])) { @@ -2266,7 +2288,7 @@ EOT; ->orderBy('grade desc, `order`') ->get(); $stmt = $this->dbh->query($query); - while($module = $stmt->fetch()) + while ($module = $stmt->fetch()) { $this->buildTree($treeMenu, $type, $objectID, $rootID, $module, $moduleDocs, $docID); } @@ -2411,7 +2433,7 @@ EOT; /* Unit conversion. */ $i = 0; - while($sizeCount > 1024 and $i <= 4) + while ($sizeCount > 1024 and $i <= 4) { $sizeCount = $sizeCount / 1024; $i++; diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index 2f7af1329c..ab31e6a9ab 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -1061,6 +1061,36 @@ $lang->doc->methodOrder[60] = 'collect'; $lang->doc->methodOrder[65] = 'tableContents'; $lang->doc->methodOrder[70] = 'showFiles'; +/* Api Lib */ +$lang->resource->apiDoc = new stdClass(); +$lang->resource->apiDoc->index = 'index'; +$lang->resource->apiDoc->createLib = 'createLib'; +$lang->resource->apiDoc->editLib = 'editLib'; +$lang->resource->apiDoc->deleteLib = 'deleteLib'; +$lang->resource->apiDoc->publish = 'publish'; +$lang->resource->apiDoc->struct = 'structPage'; +$lang->resource->apiDoc->createStruct = 'createStruct'; +$lang->resource->apiDoc->editStruct = 'editStruct'; +$lang->resource->apiDoc->deleteStruct = 'deleteStruct'; +$lang->resource->apiDoc->create = 'createApi'; +$lang->resource->apiDoc->edit = 'editApi'; +$lang->resource->apiDoc->delete = 'deleteApi'; + +$lang->apiDoc->methodOrder[0] = 'index'; +$lang->apiDoc->methodOrder[5] = 'createLib'; +$lang->apiDoc->methodOrder[10] = 'editLib'; +$lang->apiDoc->methodOrder[15] = 'deleteLib'; +$lang->apiDoc->methodOrder[20] = 'publish'; +$lang->apiDoc->methodOrder[25] = 'structPage'; +$lang->apiDoc->methodOrder[30] = 'createStruct'; +$lang->apiDoc->methodOrder[35] = 'editStruct'; +$lang->apiDoc->methodOrder[40] = 'deleteStruct'; +$lang->apiDoc->methodOrder[45] = 'createApi'; +$lang->apiDoc->methodOrder[50] = 'editApi'; +$lang->apiDoc->methodOrder[55] = 'deleteApi'; + + + /* Mail. */ $lang->resource->mail = new stdclass(); $lang->resource->mail->index = 'index'; diff --git a/module/task/lang/zh-cn.php b/module/task/lang/zh-cn.php index a7b373aab1..c45acf1b3e 100644 --- a/module/task/lang/zh-cn.php +++ b/module/task/lang/zh-cn.php @@ -57,8 +57,8 @@ $lang->task->common = '任务'; $lang->task->id = '编号'; $lang->task->project = '所属项目'; $lang->task->execution = '所属' . $lang->execution->common; -$lang->task->module = '所属模块'; -$lang->task->moduleAB = '模块'; +$lang->task->module = '目录'; +$lang->task->moduleAB = '目录'; $lang->task->story = "相关{$lang->SRCommon}"; $lang->task->storyAB = $lang->SRCommon; $lang->task->storySpec = "{$lang->SRCommon}描述";