content.html.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <div class="main-col" data-min-width="500">
  2. <div id="mainContent" class="main-row in flex-content">
  3. <div class="main-col col-8">
  4. <div class="cell" id="content">
  5. <div class="no-padding">
  6. <div class="detail-title no-padding doc-title">
  7. <div class="http-method label"><?php echo $api->method;?></div>
  8. <div class="path" title="<?php echo $api->path;?>"><?php echo $api->path;?></div>
  9. <div class="info">
  10. <div class="version">
  11. <div class='btn-group'>
  12. <a href='javascript:;' class='btn btn-link btn-limit text-ellipsis' data-toggle='dropdown' style="max-width: 120px;">
  13. V<?php echo $version ? $version : $api->version;?>
  14. <span class="caret"></span>
  15. </a>
  16. <ul class='dropdown-menu api-version-menu menu-active-primary menu-hover-primary' style='max-height:240px; max-width: 300px; overflow-y:auto'>
  17. <?php for($itemVersion = $api->version; $itemVersion > 0; $itemVersion--):?>
  18. <li <?php if($version == $itemVersion) echo 'class=active';?> ><a href='javascript:void(0)' data-url='<?php echo $this->createLink('api', 'index', "libID={$api->lib}&moduleID=0&apiID=$apiID&version=$itemVersion&release=$release");?>'>V<?php echo $itemVersion;?></a></li>
  19. <?php endfor;?>
  20. </ul>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="actions">
  25. <?php echo html::a("javascript:fullScreen()", '<span class="icon-fullscreen"></span>', '', "title='{$lang->fullscreen}' class='btn btn-link fullscreen-btn'");?>
  26. <?php
  27. if(!$isRelease)
  28. {
  29. if(common::hasPriv('api', 'edit')) echo html::a($this->createLink('api', 'edit', "apiID=$api->id"), '<i class="icon-edit"></i>', '', "title='{$lang->api->edit}' class='btn btn-link' data-app='{$this->app->tab}'");
  30. if(common::hasPriv('api', 'delete')) echo html::a($this->createLink('api', 'delete', "apiID=$api->id"), '<i class="icon-trash"></i>', '', "title='{$lang->api->delete}' class='btn btn-link' target='hiddenwin'");
  31. }
  32. ?>
  33. <a id="hisTrigger" href="###" class="btn btn-link" title=<?php echo $lang->history?>><span class="icon icon-clock"></span></a>
  34. </div>
  35. </div>
  36. </div>
  37. <div>
  38. <h2 class="title" title="<?php echo $api->title;?>"><?php echo $api->title;?></h2>
  39. <div class="desc"><?php echo $api->desc;?></div>
  40. <?php if($api->params['header']):?>
  41. <h3 class="title"><?php echo $lang->api->header;?></h3>
  42. <table class="table table-data paramsTable">
  43. <thead>
  44. <tr>
  45. <th><?php echo $lang->api->req->name;?></th>
  46. <th><?php echo $lang->api->req->type;?></th>
  47. <th><?php echo $lang->api->req->required;?></th>
  48. <th><?php echo $lang->api->req->desc;?></th>
  49. </tr>
  50. </thead>
  51. <tbody>
  52. <?php foreach($api->params['header'] as $param):?>
  53. <tr>
  54. <td><?php echo $param['field'];?></td>
  55. <td>String</td>
  56. <td><?php echo $lang->api->boolList[$param['required']];?></td>
  57. <td><?php echo $param['desc'];?></td>
  58. <tr>
  59. <?php endforeach;?>
  60. </tbody>
  61. </table>
  62. <?php endif;?>
  63. <?php if($api->params['query']):?>
  64. <h3 class="title"><?php echo $lang->api->query;?></h3>
  65. <table class="table table-data paramsTable">
  66. <thead>
  67. <tr>
  68. <th><?php echo $lang->api->req->name;?></th>
  69. <th><?php echo $lang->api->req->type;?></th>
  70. <th><?php echo $lang->api->req->required;?></th>
  71. <th><?php echo $lang->api->req->desc;?></th>
  72. </tr>
  73. </thead>
  74. <tbody>
  75. <?php foreach($api->params['query'] as $param):?>
  76. <tr>
  77. <td><?php echo $param['field'];?></td>
  78. <td>String</td>
  79. <td><?php echo $lang->api->boolList[$param['required']];?></td>
  80. <td><?php echo $param['desc'];?></td>
  81. <tr>
  82. <?php endforeach;?>
  83. </tbody>
  84. </table>
  85. <?php endif;?>
  86. <?php
  87. function parseTree($data, $typeList, $level = 0)
  88. {
  89. global $lang;
  90. $str = '<tr>';
  91. $field = '';
  92. for($i = 0; $i < $level; $i++) $field .= '&nbsp;&nbsp;'. ($i == $level-1 ? '∟' : '&nbsp;') . '&nbsp;&nbsp;';
  93. $field .= $data['field'];
  94. $str .= '<td>' . $field . '</td>';
  95. $str .= '<td>' . zget($typeList, $data['paramsType'], '') . '</td>';
  96. $str .= '<td class="text-center">' . zget($lang->api->boolList, $data['required'], '') . '</td>';
  97. $str .= '<td>' . $data['desc'] . '</td>';
  98. $str .= '</tr>';
  99. if(isset($data['children']) && count($data['children']) > 0)
  100. {
  101. $level++;
  102. foreach($data['children'] as $item) $str .= parseTree($item, $typeList, $level);
  103. }
  104. return $str;
  105. }
  106. ?>
  107. <?php if($api->params['params']):?>
  108. <h3 class="title"><?php echo $lang->api->params;?></h3>
  109. <table class="table table-data paramsTable">
  110. <thead>
  111. <tr>
  112. <th><?php echo $lang->api->req->name;?></th>
  113. <th class="w-50px"><?php echo $lang->api->req->type;?></th>
  114. <th class="w-50px text-center"><?php echo $lang->api->req->required;?></th>
  115. <th class="w-300px"><?php echo $lang->api->req->desc;?></th>
  116. </tr>
  117. </thead>
  118. <tbody><?php foreach($api->params['params'] as $item) echo parseTree($item, $typeList);?></tbody>
  119. </table>
  120. <?php endif;?>
  121. <?php if($api->paramsExample):?>
  122. <h3 class="title"><?php echo $lang->api->paramsExample;?></h3>
  123. <pre><code><?php echo $api->paramsExample;?></code></pre>
  124. <?php endif;?>
  125. <?php if($api->response):?>
  126. <h3 class="title"><?php echo $lang->api->response;?></h3>
  127. <table class="table table-data">
  128. <thead>
  129. <tr>
  130. <th><?php echo $lang->api->req->name;?></th>
  131. <th class="w-50px"><?php echo $lang->api->req->type;?></th>
  132. <th class="w-50px text-center"><?php echo $lang->api->req->required;?></th>
  133. <th class="w-300px"><?php echo $lang->api->req->desc;?></th>
  134. </tr>
  135. </thead>
  136. <tbody>
  137. <?php foreach($api->response as $item) echo parseTree($item, $typeList);?>
  138. </tbody>
  139. </table>
  140. <?php endif;?>
  141. <?php if($api->responseExample):?>
  142. <h3 class='title'><?php echo $lang->api->responseExample;?></h3>
  143. <pre><code><?php echo $api->responseExample;?></code></pre>
  144. <?php endif;?>
  145. </div>
  146. </div>
  147. </div>
  148. <div id="history" class='panel hidden' style="margin-left: 2px;">
  149. <?php
  150. $canBeChanged = common::canBeChanged('api', $api);
  151. if($canBeChanged) $actionFormLink = $this->createLink('action', 'comment', "objectType=api&objectID=$api->id");?>
  152. <?php include '../../common/view/action.html.php';?>
  153. </div>
  154. </div>
  155. </div>