diff --git a/module/api/control.php b/module/api/control.php index 37f0e15a82..a243db1cab 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -80,6 +80,53 @@ class api extends control $this->display(); } + /** + * Release manage page. + * + * @param int $libID + * @access public + * @return void + */ + public function editPublish($libID, $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. */ + $sort = $this->loadModel('common')->appendOrder($orderBy); + $releases = $this->api->getReleaseByQuery($libID, $pager, $sort); + + $this->view->releases = $releases; + $this->view->pager = $pager; + $this->view->orderBy = $orderBy; + $this->view->title = $this->lang->api->managePublish; + $this->view->libID = $libID; + $this->display(); + } + + /** + * @param int $libID + * @param int $id + * @param string $confirm + */ + public function deleteRelease($libID, $id = 0, $confirm = 'no') + { + if($confirm == 'no') + { + echo js::confirm($this->lang->custom->notice->confirmDelete, $this->createLink('api', 'deleteRelease', "libID=$libID&id=$id&confirm=yes"), ''); + die; + } + else + { + $this->api->deletePublish($id); + if(dao::isError()) return $this->sendError(dao::getError()); + die(js::locate(inlink('editPublish', "libID=$libID"), 'parent')); + } + } + /** * Publish a api doc lib. * @@ -100,7 +147,7 @@ class api extends control ->get(); // check version is exist. - if($this->api->getReleaseByVersion($data->version)) + if($this->api->getReleaseByVersion($libID, $data->version)) { return $this->sendError($this->lang->api->noUniqueVersion); } @@ -564,7 +611,8 @@ class api extends control * @access public * @return void */ - private function setMenu($libID = 0) + private + function setMenu($libID = 0) { common::setMenuVars('doc', $libID); @@ -620,7 +668,8 @@ class api extends control * @access public * @return string */ - private function generateLibsDropMenu($libs, $libID, $version = 0) + private + function generateLibsDropMenu($libs, $libID, $version = 0) { if(empty($libs)) return ''; @@ -715,8 +764,7 @@ EOT; * @access public * @return string */ - public - function getModel($moduleName, $methodName, $params = '') + public function getModel($moduleName, $methodName, $params = '') { if(!$this->config->features->apiGetModel) die(sprintf($this->lang->api->error->disabled, '$config->features->apiGetModel')); @@ -747,8 +795,7 @@ EOT; * @access public * @return void */ - public - function debug($filePath, $action) + public function debug($filePath, $action) { $filePath = helper::safe64Decode($filePath); if($action == 'extendModel') @@ -799,7 +846,8 @@ EOT; die($this->output); } - private function getTypeOptions($libID) + private + function getTypeOptions($libID) { $options = []; foreach($this->lang->api->paramsTypeOptions as $key => $item) diff --git a/module/api/lang/zh-cn.php b/module/api/lang/zh-cn.php index 28d2b144cd..78eff4768b 100755 --- a/module/api/lang/zh-cn.php +++ b/module/api/lang/zh-cn.php @@ -59,6 +59,7 @@ $lang->api->title = '接口库'; $lang->api->module = '目录'; $lang->api->apiDoc = '接口'; $lang->api->manageType = '维护目录'; +$lang->api->managePublish = '版本管理'; $lang->api->doing = '开发中'; $lang->api->done = '开发完成'; $lang->api->basicInfo = '基本信息'; diff --git a/module/api/model.php b/module/api/model.php index f7c4cf84e3..112249ab0d 100644 --- a/module/api/model.php +++ b/module/api/model.php @@ -75,8 +75,7 @@ class apiModel extends model */ public function deletePublish($id) { - $this->dao->update(TABLE_API_LIB_RELEASE) - ->set('deleted')->eq(1) + $this->dao->delete()->from(TABLE_API_LIB_RELEASE) ->where('id')->eq($id) ->exec(); } @@ -260,15 +259,17 @@ class apiModel extends model /** * Get release by version. * - * @param $version - * @access public + * @param int $libID + * @param string $version * @return object + * @access public */ - public function getReleaseByVersion($version) + public function getReleaseByVersion($libID, $version) { $model = $this->dao->select('*') ->from(TABLE_API_LIB_RELEASE) ->where('version')->eq($version) + ->andWhere('lib')->eq($libID) ->fetch(); if($model) $model->snap = json_decode(htmlspecialchars_decode($model->snap), true); return $model; @@ -347,8 +348,8 @@ class apiModel extends model /** * Get api list by release. * - * @param object $release - * @param string $where + * @param object $release + * @param string $where * @return array */ public function getApiListByRelease($release, $where = '') @@ -464,6 +465,22 @@ class apiModel extends model ->fetchAll(); } + /** + * @param int $libID + * @param string $pager + * @param string $orderBy + * @access public + * @return array + */ + public function getReleaseByQuery($libID, $pager = '', $orderBy = '') + { + return $this->dao->select('*')->from(TABLE_API_LIB_RELEASE) + ->where('lib')->eq($libID) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll(); + } + /** * Get struct tree by lib id * diff --git a/module/api/view/editpublish.html.php b/module/api/view/editpublish.html.php new file mode 100644 index 0000000000..0d718d576e --- /dev/null +++ b/module/api/view/editpublish.html.php @@ -0,0 +1,55 @@ + + * @package doc + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +
+
+
+ +
+ + + + recTotal}&recPerPage={$pager->recPerPage}";?> + + + + + + + + + + + + + + + + + + + + +
idAB);?>api->version);?>api->desc;?>api->structAddedBy);?>api->structAddedDate);?>actions;?>
id);?>version;?>desc;?>addedBy ?>addedDate ?> + createLink('api', 'deleteRelease', "libID=$libID&id=$release->id"), '', 'hiddenwin', "title='{$lang->api->delete}' class='btn'"); + ?> +
+
+
+
+ diff --git a/module/api/view/index.html.php b/module/api/view/index.html.php index 96bd7eb3f7..135c29ea0a 100644 --- a/module/api/view/index.html.php +++ b/module/api/view/index.html.php @@ -26,6 +26,10 @@ echo html::a('javascript:;', "", '', "data-toggle='dropdown' class='btn btn-link'"); echo "