Files
EasySoft-ZenTaoPMS/module/dev/view/restapi.html.php
T

155 lines
6.5 KiB
PHP

<?php
/**
* The index view file of doc module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package doc
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('confirmDelete', $lang->api->confirmDelete);?>
<div class="fade main-row split-row" id="mainRow">
<?php $sideWidth = common::checkNotCN() ? '270' : '238';?>
<div class="side-col" style="width:<?php echo $sideWidth;?>px" data-min-width="<?php echo $sideWidth;?>">
<div class="cell" style="min-height: 286px; overflow: visible;">
<div id='title'>
<li class='menu-title'>
<div class="title"><?php echo $this->lang->api->module;?></div>
</li>
</div>
<?php echo $moduleTree;?>
</div>
</div>
<div class="main-col" data-min-width="500">
<div id="mainContent" class="main-row in">
<div class="main-col col-8">
<div class="cell" id="content">
<div class="no-padding">
<div class="detail-title no-padding doc-title">
<div class="http-method label"><?php echo $api->method;?></div>
<div class="path" title="<?php echo $api->path;?>"><?php echo $api->path;?></div>
</div>
</div>
<div>
<h2 class="title" title="<?php echo $api->title;?>"><?php echo $api->title;?></h2>
<div class="desc"><?php echo $api->desc;?></div>
<?php if($api->params['header']):?>
<h3 class="title"><?php echo $lang->api->header;?></h3>
<table class="table table-data paramsTable">
<thead>
<tr>
<th><?php echo $lang->api->req->name;?></th>
<th><?php echo $lang->api->req->type;?></th>
<th><?php echo $lang->api->req->required;?></th>
<th><?php echo $lang->api->req->desc;?></th>
</tr>
</thead>
<tbody>
<?php foreach($api->params['header'] as $param):?>
<tr>
<td><?php echo $param['field'];?></td>
<td>String</td>
<td><?php echo $lang->api->boolList[$param['required']];?></td>
<td><?php echo $param['desc'];?></td>
<tr>
<?php endforeach;
;?>
</tbody>
</table>
<?php endif;?>
<?php if($api->params['query']):?>
<h3 class="title"><?php echo $lang->api->query;?></h3>
<table class="table table-data paramsTable">
<thead>
<tr>
<th><?php echo $lang->api->req->name;?></th>
<th><?php echo $lang->api->req->type;?></th>
<th><?php echo $lang->api->req->required;?></th>
<th><?php echo $lang->api->req->desc;?></th>
</tr>
</thead>
<tbody>
<?php foreach($api->params['query'] as $param):?>
<tr>
<td><?php echo $param['field'];?></td>
<td>String</td>
<td><?php echo $lang->api->boolList[$param['required']];?></td>
<td><?php echo $param['desc'];?></td>
<tr>
<?php endforeach;
;?>
</tbody>
</table>
<?php endif;?>
<?php
function parseTree($data, $typeList, $level = 0)
{
global $lang;
$str = '<tr>';
$field = '';
for($i = 0; $i < $level; $i++) $field .= '&nbsp;&nbsp;'. ($i == $level-1 ? '∟' : '&nbsp;') . '&nbsp;&nbsp;';
$field .= $data['field'];
$str .= '<td>' . $field . '</td>';
$str .= '<td>' . zget($typeList, $data['paramsType'], '') . '</td>';
$str .= '<td class="text-center">' . zget($lang->api->boolList, $data['required'], '') . '</td>';
$str .= '<td>' . $data['desc'] . '</td>';
$str .= '</tr>';
if(isset($data['children']) && count($data['children']) > 0)
{
$level++;
foreach($data['children'] as $item) $str .= parseTree($item, $typeList, $level);
}
return $str;
}
?>
<?php if($api->params['params']):?>
<h3 class="title"><?php echo $lang->api->params;?></h3>
<table class="table table-data paramsTable">
<thead>
<tr>
<th><?php echo $lang->api->req->name;?></th>
<th class="w-50px"><?php echo $lang->api->req->type;?></th>
<th class="w-50px text-center"><?php echo $lang->api->req->required;?></th>
<th class="w-300px"><?php echo $lang->api->req->desc;?></th>
</tr>
</thead>
<tbody><?php foreach($api->params['params'] as $item) echo parseTree($item, $typeList);?></tbody>
</table>
<?php endif;?>
<?php if($api->paramsExample):?>
<h3 class="title"><?php echo $lang->api->paramsExample;?></h3>
<pre><code><?php echo $api->paramsExample;?></code></pre>
<?php endif;?>
<?php if($api->response):?>
<h3 class="title"><?php echo $lang->api->response;?></h3>
<table class="table table-data">
<thead>
<tr>
<th><?php echo $lang->api->req->name;?></th>
<th class="w-50px"><?php echo $lang->api->req->type;?></th>
<th class="w-50px text-center"><?php echo $lang->api->req->required;?></th>
<th class="w-300px"><?php echo $lang->api->req->desc;?></th>
</tr>
</thead>
<tbody>
<?php foreach($api->response as $item) echo parseTree($item, $typeList);?>
</tbody>
</table>
<?php endif;?>
<?php if($api->responseExample):?>
<h3 class='title'><?php echo $lang->api->responseExample;?></h3>
<pre><code><?php echo $api->responseExample;?></code></pre>
<?php endif;?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include '../../common/view/footer.html.php';?>