* Add api priv and switch api doc release locate.

This commit is contained in:
caoyanyi
2023-04-07 09:30:02 +08:00
parent 4260e92cdd
commit ea55ca8c33
10 changed files with 88 additions and 19 deletions
+34 -1
View File
@@ -49,6 +49,12 @@ class api extends control
$objectID = $this->objectID;
$isFirstLoad = $libID ? false : true;
if($release)
{
$browseType = 'byrelease';
$param = $release;
}
/* Get all api doc libraries. */
$libs = $this->doc->getApiLibs($appendLib, $objectType, $objectID);
if(empty($libs) and $objectType != 'nolink')
@@ -125,7 +131,7 @@ class api extends control
$this->view->objectID = $objectID;
$this->view->moduleID = $moduleID;
$this->view->version = $version;
$this->view->libTree = $this->doc->getLibTree($libID, $libs, 'api', $moduleID, $objectID, $browseType);
$this->view->libTree = $this->doc->getLibTree($libID, $libs, 'api', $moduleID, $objectID, $browseType, $param);
$this->view->users = $this->user->getPairs('noclosed,noletter');
$this->view->objectDropdown = isset($libs[$libID]) ? $this->generateLibsDropMenu($libs[$libID], $release) : '';
@@ -931,4 +937,31 @@ class api extends control
$this->display();
}
/**
* Edit a catalog.
*
* @param int $moduleID
* @param string $type doc|api
* @access public
* @return void
*/
public function editCatalog($moduleID, $type)
{
echo $this->fetch('tree', 'edit', "moduleID=$moduleID&type=$type");
}
/**
* Delete a catalog.
*
* @param int $rootID
* @param int $moduleID
* @param string $confirm yes|no
* @access public
* @return void
*/
public function deleteCatalog($rootID, $moduleID, $confirm = 'no')
{
echo $this->fetch('tree', 'delete', "rootID=$rootID&moduleID=$moduleID&confirm=$confirm");
}
}
+3
View File
@@ -61,6 +61,9 @@ $lang->api->zentaoAPI = "Zentao API v1";
$lang->api->search = "Search";
$lang->api->allLibs = "AllLibs";
$lang->api->noLinked = "No Linked";
$lang->api->addCatalog = 'Add Catalog';
$lang->api->editCatalog = 'Edit Catalog';
$lang->api->deleteCatalog = 'Delete Catalog';
/* Common access control lang. */
$lang->api->whiteList = 'Whitelist';
+3
View File
@@ -61,6 +61,9 @@ $lang->api->zentaoAPI = "Zentao API v1";
$lang->api->search = "Search";
$lang->api->allLibs = "AllLibs";
$lang->api->noLinked = "No Linked";
$lang->api->addCatalog = 'Add Catalog';
$lang->api->editCatalog = 'Edit Catalog';
$lang->api->deleteCatalog = 'Delete Catalog';
/* Common access control lang. */
$lang->api->whiteList = 'Whitelist';
+3
View File
@@ -61,6 +61,9 @@ $lang->api->zentaoAPI = "Zentao API v1";
$lang->api->search = "Search";
$lang->api->allLibs = "AllLibs";
$lang->api->noLinked = "No Linked";
$lang->api->addCatalog = 'Add Catalog';
$lang->api->editCatalog = 'Edit Catalog';
$lang->api->deleteCatalog = 'Delete Catalog';
/* Common access control lang. */
$lang->api->whiteList = 'Whitelist';
+3
View File
@@ -61,6 +61,9 @@ $lang->api->zentaoAPI = "禅道API文档v1";
$lang->api->search = "搜索";
$lang->api->allLibs = "全部库";
$lang->api->noLinked = "无关联";
$lang->api->addCatalog = '添加目录';
$lang->api->editCatalog = '编辑目录';
$lang->api->deleteCatalog = '删除目录';
/* Common access control lang. */
$lang->api->whiteList = '白名单';
+2 -1
View File
@@ -1303,7 +1303,7 @@ class doc extends control
$this->view->isFirstLoad = $isFirstLoad;
$this->view->param = $queryID;
$this->view->users = $this->user->getPairs('noletter');
$this->view->libTree = $this->doc->getLibTree($libID, $libs, $type, $moduleID, $objectID, $browseType);
$this->view->libTree = $this->doc->getLibTree($libID, $libs, $type, $moduleID, $objectID, $browseType, $param);
$this->view->libID = $libID;
$this->view->moduleID = $moduleID;
$this->view->objectDropdown = $objectDropdown;
@@ -1312,6 +1312,7 @@ class doc extends control
$this->view->pager = $pager;
$this->view->objectID = $objectID;
$this->view->orderBy = $orderBy;
$this->view->release = $browseType == 'byrelease' ? $param : 0;
$this->view->canExport = $libType == 'api' ? common::hasPriv('api', 'export') : common::hasPriv('doc', $type . '2export');
$this->view->exportMethod = $libType == 'api' ? 'export' : $type . '2export';
$this->view->apiLibID = key($apiLibs);
+14 -4
View File
@@ -2787,9 +2787,9 @@ class docModel extends model
* @access public
* @return array
*/
public function getModuleTree($rootID, $moduleID = 0, $type = 'doc', $parent = 0, &$modules = array())
public function getModuleTree($rootID, $moduleID = 0, $type = 'doc', $parent = 0, $modules = array())
{
if(empty($modules))
if(is_array($modules) and empty($modules))
{
$modules = $this->dao->select('*')->from(TABLE_MODULE)
->where('root')->eq((int)$rootID)
@@ -2843,10 +2843,11 @@ class docModel extends model
* @param int $objectID
* @param int $executionID
* @param string $browseType bySearch
* @param int $param
* @access public
* @return array
*/
public function getLibTree($libID, $libs, $type, $moduleID, $objectID = 0, $browseType = '')
public function getLibTree($libID, $libs, $type, $moduleID, $objectID = 0, $browseType = '', $param = 0)
{
if($type == 'project')
{
@@ -2862,11 +2863,20 @@ class docModel extends model
->fetchPairs();
}
$release = null;
if($browseType == 'byrelease' and $param) $release = $this->loadModel('api')->getRelease(0, 'byId', $param);
$libTree = array($type => array());
$apiLibs = array();
$apiLibIDList = array();
foreach($libs as $lib)
{
$releaseModule = array();
if($release and $release->lib == $lib->id)
{
foreach($release->snap['modules'] as $module) $releaseModule[$module['id']] = (object)$module;
}
$item = new stdclass();
$item->id = $lib->id;
$item->type = $lib->type == 'api' ? 'api' : 'lib';
@@ -2874,7 +2884,7 @@ class docModel extends model
$item->objectType = $type;
$item->objectID = $objectID;
$item->active = $lib->id == $libID && $browseType != 'bySearch' ? 1 : 0;
$item->children = $this->getModuleTree($lib->id, $moduleID, $lib->type == 'api' ? 'api' : 'doc');
$item->children = $this->getModuleTree($lib->id, $moduleID, $lib->type == 'api' ? 'api' : 'doc', 0, $releaseModule);
$showDoc = $this->loadModel('setting')->getItem('owner=' . $this->app->user->account . '&module=doc&key=showDoc');
$showDoc = $showDoc === '0' ? 0 : 1;
if($this->app->rawMethod == 'view' and $lib->type != 'api' and $showDoc)
+16 -9
View File
@@ -187,15 +187,15 @@ $(function()
}
else
{
var libId;
var lib = 0;
var $lis = '<li><a href="###" data-id=0>' + versionLang + '</a></li>';
for(i = 0; i< versions.length; i++)
{
var version = versions[i];
$lis += '<li><a href="###" data-id="' + version.id + '">' + version.version+ '</a></li>';
libId = version.lib;
lib = version.lib;
}
var $dropdown = '<ul id="versionSwitcher" data-lib-id = "' + libId + '" class="dropdown-menu dropdown-in-tree" style="display: unset; left:' + option.left + 'px; top:' + option.top + 'px;">';
var $dropdown = '<ul id="versionSwitcher" data-lib = "' + lib + '" class="dropdown-menu dropdown-in-tree" style="display: unset; left:' + option.left + 'px; top:' + option.top + 'px;">';
$dropdown += $lis;
$dropdown += '</ul>';
}
@@ -360,7 +360,7 @@ $(function()
libID = $(this).closest('.lib').data('id');
}
return lcatePage(libID, moduleID, $(this).data('type'));
return locatePage(libID, moduleID, $(this).data('type'));
}).on('click', '.tree-version-trigger', function(e)
{
$('.dropdown-in-tree').remove();
@@ -408,7 +408,7 @@ $(function()
* @access public
* @return void
*/
function lcatePage(libID, moduleID, type)
function locatePage(libID, moduleID, type)
{
linkParams = linkParams.replace('%s', 'libID=' + libID + '&moduleID=' + moduleID);
var methodName = '';
@@ -548,9 +548,16 @@ $(function()
}
}).on('click', '#versionSwitcher a', function()
{
var $item = $(this);
linkParams = linkParams.replace('%s', 'libID=' + $item.closest('ul').data('libId') + '&moduleID=0&apiID=0&version=0&release=' + $item.data('id'));
location.href = createLink(config.currentModule, 'index', linkParams);
var libID = $(this).closest('#versionSwitcher').data('lib');
var moduleID = $(this).data('id');
var params = 'libID=' + libID + '&moduleID=0&apiID=0&version=0&release=' + moduleID;
var methodName = config.currentMethod;
if(config.currentModule == 'doc')
{
params = linkParams.replace('%s', 'libID=' + libID + '&moduleID=' + moduleID).replace('browseType=&', 'browseType=byrelease&').replace('param=0', 'param=' + moduleID);
methodName = objectType + 'Space';
}
location.href = createLink(config.currentModule, methodName, params);
}).on('blur', '.file-tree input.input-tree', function()
{
var $input = $(this);
@@ -583,7 +590,7 @@ $(function()
}
var module = result.module;
return lcatePage(module.root, module.id, 'doc');
return locatePage(module.root, module.id, 'doc');
});
}).on('keydown', '.file-tree input.input-tree', function(e)
{
+1 -1
View File
@@ -12,7 +12,7 @@
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('treeData', $libTree);?>
<?php js::set('linkParams', "objectID=$objectID&%s&browseType=&orderBy=$orderBy");?>
<?php js::set('linkParams', "objectID=$objectID&%s&browseType=&orderBy=$orderBy&param=0");?>
<?php js::set('docLang', $lang->doc);?>
<?php js::set('libType', $libType);?>
<div id="mainMenu" class="clearfix">
+9 -3
View File
@@ -1898,6 +1898,9 @@ $lang->resource->api->deleteStruct = 'deleteStruct';
$lang->resource->api->create = 'create';
$lang->resource->api->edit = 'edit';
$lang->resource->api->delete = 'delete';
$lang->resource->api->addCatalog = 'addCatalog';
$lang->resource->api->editCatalog = 'editCatalog';
$lang->resource->api->deleteCatalog = 'deleteCatalog';
$lang->resource->api->getModel = 'getModel';
$lang->resource->api->debug = 'debug';
@@ -1917,9 +1920,12 @@ $lang->api->methodOrder[50] = 'deleteStruct';
$lang->api->methodOrder[55] = 'create';
$lang->api->methodOrder[60] = 'edit';
$lang->api->methodOrder[65] = 'delete';
$lang->api->methodOrder[70] = 'getModel';
$lang->api->methodOrder[75] = 'debug';
$lang->api->methodOrder[80] = 'sql';
$lang->api->methodOrder[70] = 'addCatalog';
$lang->api->methodOrder[75] = 'editCatalog';
$lang->api->methodOrder[80] = 'deleteCatalog';
$lang->api->methodOrder[85] = 'getModel';
$lang->api->methodOrder[90] = 'debug';
$lang->api->methodOrder[95] = 'sql';
$lang->resource->file = new stdclass();
$lang->resource->file->download = 'download';