*Finish task #57888
This commit is contained in:
@@ -27,3 +27,29 @@ $config->api->editor->edit = array('id' => 'desc', 'tools' => 'simpleTo
|
||||
$config->api->editor->createRelease = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->api->editor->createstruct = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->api->editor->editstruct = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
|
||||
global $lang;
|
||||
$config->api->search['module'] = 'api';
|
||||
$config->api->search['fields']['title'] = $lang->api->title;
|
||||
$config->api->search['fields']['id'] = $lang->api->id;
|
||||
$config->api->search['fields']['lib'] = $lang->api->lib;
|
||||
$config->api->search['fields']['path'] = $lang->api->path;
|
||||
$config->api->search['fields']['method'] = $lang->api->method;
|
||||
$config->api->search['fields']['status'] = $lang->api->status;
|
||||
$config->api->search['fields']['addedBy'] = $lang->api->addedBy;
|
||||
$config->api->search['fields']['addedDate'] = $lang->api->addedDate;
|
||||
$config->api->search['fields']['editedBy'] = $lang->api->editedBy;
|
||||
$config->api->search['fields']['editedDate'] = $lang->api->editedDate;
|
||||
$config->api->search['fields']['version'] = $lang->api->version;
|
||||
|
||||
$config->api->search['params']['title'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
|
||||
$config->api->search['params']['id'] = array('operator' => '=', 'control' => 'input', 'values' => '');
|
||||
$config->api->search['params']['lib'] = array('operator' => '=', 'control' => 'select', 'values' => '');
|
||||
$config->api->search['params']['path'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
|
||||
$config->api->search['params']['method'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $lang->api->methodOptions);
|
||||
$config->api->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => array('' => '') + $lang->api->statusOptions);
|
||||
$config->api->search['params']['addedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users');
|
||||
$config->api->search['params']['addedDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date');
|
||||
$config->api->search['params']['editedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users');
|
||||
$config->api->search['params']['editedDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date');
|
||||
$config->api->search['params']['version'] = array('operator' => '>=', 'control' => 'input', 'values' => '');
|
||||
|
||||
+17
-2
@@ -28,10 +28,12 @@ class api extends control
|
||||
* @param int $version
|
||||
* @param int $release
|
||||
* @param int $appendLib
|
||||
* @param int $queryID
|
||||
* @param string $param
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0, $release = 0, $appendLib = 0)
|
||||
public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0, $release = 0, $appendLib = 0, $queryID = 0, $param = '')
|
||||
{
|
||||
/* Get all api doc libraries. */
|
||||
$libs = $this->doc->getApiLibs($appendLib);
|
||||
@@ -71,6 +73,18 @@ class api extends control
|
||||
|
||||
$this->setMenu($libID, $moduleID);
|
||||
|
||||
/* Build the search form. */
|
||||
$queryID = $param == 'bySearch' ? (int)$queryID : 0;
|
||||
$actionURL = $this->createLink('api', 'index', "libID=$libID&moduleID=$moduleID&apiID=$apiID&version=$version&release=$release&appendLib=$appendLib&queryID=myQueryID¶m=bySearch");
|
||||
$this->api->buildSearchForm($lib,$queryID, $actionURL);
|
||||
|
||||
if($param == 'bySearch')
|
||||
{
|
||||
$apiList = $this->api->getApiListBySearch($libID, $queryID);
|
||||
$this->view->apiList = $apiList;
|
||||
$this->view->typeList = $this->api->getTypeList($libID);
|
||||
}
|
||||
|
||||
$this->view->lib = $lib;
|
||||
$this->view->isRelease = $release > 0;
|
||||
$this->view->release = $release;
|
||||
@@ -78,6 +92,7 @@ class api extends control
|
||||
$this->view->libID = $libID;
|
||||
$this->view->apiID = $apiID;
|
||||
$this->view->libs = $libs;
|
||||
$this->view->param = $param;
|
||||
$this->view->moduleTree = $libID ? $this->doc->getApiModuleTree($libID, $apiID, $release, $moduleID) : '';
|
||||
$this->view->users = $this->user->getPairs('noclosed,noletter');
|
||||
|
||||
@@ -601,7 +616,7 @@ class api extends control
|
||||
common::setMenuVars('doc', $libID);
|
||||
|
||||
/* Global struct link. */
|
||||
$menu = '';
|
||||
$menu = '<a class="btn btn-link querybox-toggle" id="bysearchTab"><i class="icon icon-search muted"></i> ' . $this->lang->api->search . '</a>';
|
||||
|
||||
if($libID and common::hasPriv('api', 'createRelease'))
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
.article-content {width: 100%; display: inline-block;}
|
||||
.outline {position: relative;}
|
||||
.outline .outline-toggle i.icon-angle-right, i.icon-angle-left {width: 18px; height: 18px; background: #efefef; border-radius: 50%; position: absolute; padding-left: 2px; padding-top: 1px;}
|
||||
.outline .outline-toggle i.icon-angle-right, i.icon-angle-left {width: 18px; height: 18px; border-radius: 50%; position: absolute; padding-left: 2px; padding-top: 1px;}
|
||||
.outline .outline-toggle i.icon-angle-right:before {content: "\e314"; cursor: pointer;}
|
||||
.outline .outline-toggle i.icon-angle-left:before {content: "\e315"; cursor: pointer;}
|
||||
.outline ul li {list-style: none;}
|
||||
|
||||
@@ -15,6 +15,7 @@ $(document).ready(function()
|
||||
$('#outline li.has-list>i+ul').prev('i').remove();
|
||||
});
|
||||
});
|
||||
if(apiID > 0) $("#bysearchTab").remove();
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,6 +60,8 @@ $lang->api->confirmDeleteLib = "Do you want to delete this interface library?";
|
||||
$lang->api->filterStruct = "use struct";
|
||||
$lang->api->defaultVersion = "Current Version";
|
||||
$lang->api->zentaoAPI = "Zentao API v1";
|
||||
$lang->api->search = "Search";
|
||||
$lang->api->allLibs = "AllLibs";
|
||||
|
||||
/* Common access control lang. */
|
||||
$lang->api->whiteList = 'Whitelist';
|
||||
@@ -124,6 +126,12 @@ $lang->api->query = 'Parameter';
|
||||
$lang->api->params = 'Request Body';
|
||||
$lang->api->response = 'Response';
|
||||
$lang->api->responseExample = 'Response Example';
|
||||
$lang->api->id = 'ID';
|
||||
$lang->api->addedBy = 'AddedBy';
|
||||
$lang->api->addedDate = 'AddedDate';
|
||||
$lang->api->editedBy = 'EditedBy';
|
||||
$lang->api->editedDate = 'EditedDate';
|
||||
$lang->api->version = 'Version';
|
||||
$lang->api->res = new stdClass();
|
||||
$lang->api->res->name = 'Name';
|
||||
$lang->api->res->desc = 'Description';
|
||||
|
||||
@@ -60,6 +60,8 @@ $lang->api->confirmDeleteLib = "您确定删除该接口库吗?";
|
||||
$lang->api->filterStruct = "使用数据结构填充";
|
||||
$lang->api->defaultVersion = "当前版本";
|
||||
$lang->api->zentaoAPI = "禅道API文档v1";
|
||||
$lang->api->search = "搜索";
|
||||
$lang->api->allLibs = "全部接口库";
|
||||
|
||||
/* Common access control lang. */
|
||||
$lang->api->whiteList = '白名单';
|
||||
@@ -124,6 +126,12 @@ $lang->api->query = '请求参数';
|
||||
$lang->api->params = '请求体';
|
||||
$lang->api->response = '请求响应';
|
||||
$lang->api->responseExample = '响应示例';
|
||||
$lang->api->id = '接口编号';
|
||||
$lang->api->addedBy = '由谁添加';
|
||||
$lang->api->addedDate = '添加时间';
|
||||
$lang->api->editedBy = '由谁更新';
|
||||
$lang->api->editedDate = '更新时间';
|
||||
$lang->api->version = '版本号';
|
||||
$lang->api->res = new stdClass();
|
||||
$lang->api->res->name = '名称';
|
||||
$lang->api->res->desc = '描述';
|
||||
|
||||
@@ -895,4 +895,63 @@ class apiModel extends model
|
||||
$file = $this->app->getAppRoot() . 'db' . DS . 'api' . DS . $version . DS . $table;
|
||||
return unserialize(preg_replace_callback('#s:(\d+):"(.*?)";#s', function($match){return 's:'.strlen($match[2]).':"'.$match[2].'";';}, file_get_contents($file)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build search form.
|
||||
*
|
||||
* @param object $lib
|
||||
* @param string $queryID
|
||||
* @param string $actionURL
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function buildSearchForm($lib, $queryID, $actionURL)
|
||||
{
|
||||
$lib = array($lib->id => $lib->name);
|
||||
$this->config->api->search['module'] = 'api';
|
||||
$this->config->api->search['queryID'] = $queryID;
|
||||
$this->config->api->search['actionURL'] = $actionURL;
|
||||
$this->config->api->search['params']['lib']['values'] = $lib + array('all' => $this->lang->api->allLibs);
|
||||
|
||||
$this->loadModel('search')->setSearchParams($this->config->api->search);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get api by search.
|
||||
*
|
||||
* @param string $libID
|
||||
* @param int $queryID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getApiListBySearch($libID, $queryID)
|
||||
{
|
||||
if($queryID)
|
||||
{
|
||||
$query = $this->loadModel('search')->getQuery($queryID);
|
||||
if($query)
|
||||
{
|
||||
$this->session->set('apiQuery', $query->sql);
|
||||
$this->session->set('apiForm', $query->form);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set('apiQuery', ' 1 = 1');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->session->apiQuery == false) $this->session->set('apiQuery', ' 1 = 1');
|
||||
}
|
||||
|
||||
$apiQuery = $this->session->apiQuery;
|
||||
$list = $this->dao->select('*')
|
||||
->from(TABLE_API)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere(str_replace("`lib` = 'all'", '1', $apiQuery))
|
||||
->beginIF(strpos($apiQuery, "`lib` = 'all'") === false)->andWhere('lib')->eq($libID)->fi()
|
||||
->fetchAll();
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php js::set('confirmDelete', $lang->api->confirmDelete);?>
|
||||
<?php js::set('apiID', $apiID);?>
|
||||
<div class="cell<?php if($param == 'bySearch') echo ' show';?>" id="queryBox" data-module=<?php echo 'api';?>></div>
|
||||
<div class="fade main-row split-row" id="mainRow">
|
||||
<?php if($libID):?>
|
||||
<?php $sideWidth = common::checkNotCN() ? '270' : '238';?>
|
||||
|
||||
Reference in New Issue
Block a user