From 8944424005a381d1730b698d40d2ad9db3be742d Mon Sep 17 00:00:00 2001
From: tianshujie
Date: Tue, 21 Mar 2023 16:01:35 +0800
Subject: [PATCH] * Code for finish task #87405.
---
module/api/css/index.css | 72 ---------------
module/api/model.php | 10 +-
module/api/view/apilist.html.php | 116 +++++++++++++++++++++++
module/api/view/index.html.php | 46 +---------
module/doc/config.php | 4 +-
module/doc/control.php | 49 +++++-----
module/doc/css/tablecontents.css | 1 +
module/doc/js/tablecontents.js | 10 --
module/doc/lang/zh-cn.php | 2 +-
module/doc/model.php | 72 +++++----------
module/doc/view/doclist.html.php | 117 ++++++++++++++++++++++++
module/doc/view/tablecontents.html.php | 122 ++++---------------------
12 files changed, 309 insertions(+), 312 deletions(-)
create mode 100644 module/api/view/apilist.html.php
create mode 100644 module/doc/view/doclist.html.php
diff --git a/module/api/css/index.css b/module/api/css/index.css
index da05670e8f..fdb6b9e587 100644
--- a/module/api/css/index.css
+++ b/module/api/css/index.css
@@ -53,78 +53,6 @@
.no-content-button {text-align: center; padding-top: 20px;}
.no-content-button a:nth-child(2) {margin-left: 20px;}
-.detail .list-group-item .heading.GET {
- background-color: #e7f0f7;
-}
-.detail .list-group-item .heading.GET a {
- color: #0f6ab4;
-}
-
-.detail .list-group-item .heading.OPTIONS {
- background-color: #e7f0f7;
-}
-.detail .list-group-item .heading.OPTIONS a {
- color: #0f6ab4;
-}
-
-.detail .list-group-item .heading.POST {
- background-color: #e7f6ec;
-}
-.detail .list-group-item .heading.POST a {
- color: #10a54a;
-}
-
-.detail .list-group-item .heading.PUT {
- background-color: #f9f2e9;
-}
-.detail .list-group-item .heading.PUT a {
- color: #c5862b;
-}
-.detail .list-group-item .heading.PATCH {
- background-color: #f9f2e9;
-}
-.detail .list-group-item .heading.PATCH a {
- color: #c5862b;
-}
-
-.detail .list-group-item .heading.DELETE {
- background-color: #f5e8e8;
- border: 1px solid #e8c6c7;
-}
-.detail .list-group-item .heading.DELETE a {
- color: #a41e22;
-}
-
-.detail .list-group-item a {
- display: flex;
- align-items: center;
-}
-
-.detail .list-group-item .path, .detail .list-group-item .desc {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.detail .list-group-item .path {
- padding-left: 10px;
- font-size: 14px;
- color: black;
- flex: 1;
-}
-.detail .list-group-item .desc {
- width: auto;
- font-size: 14px;
- line-height: 38px;
- float: right;
- padding-right: 10px;
- max-width: 200px;
-}
-.detail .list-group-item {list-style: none; font-size: 14px; margin-bottom: 10px; line-height: 30px}
-.detail .list-group-item span {line-height: 30px; width: 65px;}
-.detail .list-group-item .label+.label {margin-left: -4px;}
-.detail .list-group-item .label {border-radius: 0;}
-
.paramsTable th {text-align: left!important; font-size: 14px;}
.paramsTable td {text-align: left;}
diff --git a/module/api/model.php b/module/api/model.php
index 2b9a30db5f..9386e0a1c3 100644
--- a/module/api/model.php
+++ b/module/api/model.php
@@ -394,12 +394,13 @@ class apiModel extends model
/**
* Get api doc list by module id.
*
- * @param int $libID
- * @param int $moduleID
- * @param int $release
+ * @param int $libID
+ * @param int $moduleID
+ * @param int $release
+ * @param object $pager
* @return array $list
*/
- public function getListByModuleId($libID = 0, $moduleID = 0, $release = 0)
+ public function getListByModuleId($libID = 0, $moduleID = 0, $release = 0, $pager = null)
{
/* Get release info. */
if($release > 0)
@@ -437,6 +438,7 @@ class apiModel extends model
->from(TABLE_API)
->where($where)
->andWhere('deleted')->eq(0)
+ ->page($pager)
->fetchAll();
}
array_map(function ($item) {
diff --git a/module/api/view/apilist.html.php b/module/api/view/apilist.html.php
new file mode 100644
index 0000000000..aac4c6c23f
--- /dev/null
+++ b/module/api/view/apilist.html.php
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
0 ? $lang->api->apiList : $lang->api->pageTitle;?>
+
+
+
api->noLib : $lang->api->noApi;?>
+
+ ' . $lang->api->createApi, '', 'class="btn btn-info btn-wide"');
+ }
+ ?>
+
+
+
+
+
+
+
api->baseUrl . ': ' . $lib->baseUrl;?>
+
+
+
+
+
diff --git a/module/api/view/index.html.php b/module/api/view/index.html.php
index 8a072c2d8f..14db46904e 100644
--- a/module/api/view/index.html.php
+++ b/module/api/view/index.html.php
@@ -51,50 +51,6 @@
-
-
-
-
-
-
-
-
0 ? $lang->api->apiList : $lang->api->pageTitle;?>
-
-
-
-
api->noLib : $lang->api->noApi;?>
-
- ' . $lang->api->createApi, '', 'class="btn btn-info btn-wide"');
- }
- ?>
-
-
-
-
-
-
-
api->baseUrl . ': ' . $lib->baseUrl;?>
-
-
-
-
-
+
diff --git a/module/doc/config.php b/module/doc/config.php
index 1d3d7bf145..07eb2ca46c 100644
--- a/module/doc/config.php
+++ b/module/doc/config.php
@@ -45,11 +45,11 @@ if($app->rawMethod == 'contribute') $config->doc->search['fields']['project'] =
$config->doc->search['fields']['execution'] = $lang->doc->execution;
$config->doc->search['fields']['lib'] = $lang->doc->lib;
$config->doc->search['fields']['module'] = $lang->doc->module;
-$config->doc->search['fields']['keywords'] = $lang->doc->keywords;
-$config->doc->search['fields']['addedBy'] = $lang->doc->addedBy;
+$config->doc->search['fields']['addedBy'] = $lang->doc->addedByAB;
$config->doc->search['fields']['addedDate'] = $lang->doc->addedDate;
$config->doc->search['fields']['editedBy'] = $lang->doc->editedBy;
$config->doc->search['fields']['editedDate'] = $lang->doc->editedDate;
+$config->doc->search['fields']['keywords'] = $lang->doc->keywords;
$config->doc->search['fields']['version'] = $lang->doc->version;
$config->doc->search['params']['title'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
diff --git a/module/doc/control.php b/module/doc/control.php
index 9f7ca819b9..480f704f30 100755
--- a/module/doc/control.php
+++ b/module/doc/control.php
@@ -1019,8 +1019,7 @@ class doc extends control
if(!empty($_POST)) $searchTitle = $this->post->title;
if(empty($_POST) and !empty($searchTitle)) $this->post->title = $searchTitle;
- $this->lang->TRActions = $this->doc->buildCollectButton4Doc();
- $this->lang->TRActions .= $this->doc->buildBrowseSwitch($type, $objectID, $viewType, $orderBy, $recTotal, $recPerPage, $pageID, $searchTitle);
+ $this->lang->TRActions = $this->doc->buildBrowseSwitch($type, $objectID, $viewType, $orderBy, $recTotal, $recPerPage, $pageID, $searchTitle);
/* Load pager. */
$this->app->loadClass('pager', $static = true);
@@ -1134,9 +1133,6 @@ class doc extends control
/* Set Custom. */
foreach(explode(',', $this->config->doc->customObjectLibs) as $libType) $customObjectLibs[$libType] = $this->lang->doc->customObjectLibs[$libType];
- $actionURL = $this->createLink('doc', 'tableContents', "type=$type&objectID=$objectID&libID=$libID&browseType=bySearch¶m=myQueryID");
- $this->doc->buildSearchForm(0, array(), 0, $actionURL, $type);
-
$moduleTree = $type == 'book' ? $this->doc->getBookStructure($libID) : $this->doc->getTreeMenu($type, $objectID, $libID, 0, $docID);
/* Get doc. */
@@ -1267,13 +1263,13 @@ class doc extends control
$libID = (int)$libID;
$moduleTree = $type == 'book' ? $this->doc->getBookStructure($libID) : $this->doc->getTreeMenu($type, $objectID, $libID);
- $libTree = $this->doc->getLibTree($libID, $libs, $type, $moduleID, $objectID);
+ $libTree = $this->doc->getLibTree($libID, $libs, $type, $moduleID, $objectID, $browseType);
$title = ($type == 'book' or $type == 'custom') ? $this->lang->doc->tableContents : $object->name . $this->lang->colon . $this->lang->doc->tableContents;
/* Build the search form. */
$queryID = $browseType == 'bySearch' ? (int)$param : 0;
- $actionURL = $this->createLink('doc', 'tableContents', "type=$type&objectID=$objectID&libID=0&browseType=bySearch¶m=myQueryID");
+ $actionURL = $this->createLink('doc', 'tableContents', "type=$type&objectID=$objectID&libID=$libID&moduleID=0&browseType=bySearch¶m=myQueryID");
$this->doc->buildSearchForm($libID, $libs, $queryID, $actionURL, $type);
/* Load pager. */
@@ -1283,6 +1279,27 @@ class doc extends control
$pager = new pager($recTotal, $recPerPage, $pageID);
$this->app->rawMethod = $rawMethod;
+ $this->view->libID = $libID;
+
+ $lib = $this->doc->getLibById($libID);
+ $libType = zget($lib, 'type', '');
+ if($libType == 'api')
+ {
+ $this->view->lib = $lib;
+ $this->view->libs = $libs;
+ $this->view->apiID = 0;
+ $this->view->release = 0;
+ $this->view->apiList = $this->loadModel('api')->getListByModuleId($libID, $moduleID, 0, $pager);
+ }
+ elseif($browseType == 'annex')
+ {
+ //$this->view->files = $this->doc->getLibFiles($type, $objectID, 'id_desc', $pager);
+ }
+ else
+ {
+ $this->view->docs = $browseType == 'bySearch' ? $this->doc->getDocsBySearch($type, $objectID, $libID, $queryID, $pager) : $this->doc->getDocs($libID, $moduleID, 'id_desc', $pager);
+ }
+
$this->view->title = $title;
$this->view->type = $type;
$this->view->browseType = $browseType;
@@ -1291,23 +1308,11 @@ class doc extends control
$this->view->libTree = $libTree;
$this->view->moduleID = $moduleID;
$this->view->objectDropdown = $objectDropdown;
- $this->view->docs = $browseType == 'bySearch' ? $this->doc->getDocsBySearch($type, $objectID, 0, $queryID, $pager) : $this->doc->getDocs($libID, $moduleID, 'id_desc', $pager);
+ $this->view->libType = $libType;
$this->view->pager = $pager;
+ $this->view->objectID = $objectID;
- if($browseType == 'bySearch')
- {
- $this->view->browseType = 'bySearch';
- $this->display('doc', 'browse', "browseType=bySearch¶m=$queryID");
- }
- else
- {
- $this->view->libs = $libs;
- $this->view->objectID = $objectID;
- $this->view->libID = $libID;
- $this->view->moduleTree = $moduleTree;
-
- $this->display();
- }
+ $this->display();
}
/**
diff --git a/module/doc/css/tablecontents.css b/module/doc/css/tablecontents.css
index 585a5b4aed..44034927e2 100644
--- a/module/doc/css/tablecontents.css
+++ b/module/doc/css/tablecontents.css
@@ -60,6 +60,7 @@ li.drag-shadow ul {display: none!important;}
.createDropdown a.btn-primary, .createDropdown a.btn-info {border-right: 1px solid rgba(255,255,255,0.2);}
.createDropdown button.dropdown-toggle.btn-primary, .createDropdown button.dropdown-toggle.btn-info {padding: 6px;}
.createDropdown ul > li {text-align: left;}
+.createDropdown .btn.btn-info:hover {box-shadow: none;}
.table .c-name > a.text-primary {display: inline-block; max-width: 90%; overflow: hidden;}
.table .c-name > .ajaxCollect {float: right; position: relative; right: 10px; top: -3px;}
diff --git a/module/doc/js/tablecontents.js b/module/doc/js/tablecontents.js
index 2a4b96dea7..946e18bb47 100644
--- a/module/doc/js/tablecontents.js
+++ b/module/doc/js/tablecontents.js
@@ -1,15 +1,5 @@
$(function()
{
- if(!moduleTree || moduleTree.length == 0)
- {
- var contentHeight = $('.no-content').parent().innerHeight();
- var titleHeight = $('.cell div:nth-child(1)').innerHeight();
-
- var height = $(document).height() - $('#header').height() - parent.$('#appsBar').height() - (2 * parseInt($('#main').css('padding-top')));
- $('.main-content .cell').height(height);
- $('.no-content').parent().css('padding-top', (height - contentHeight)/2 - titleHeight + 'px');
- }
-
$('#main .main-content li.has-list').addClass('open in');
$('.menu-actions > a').click(function()
diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php
index 1e0ab79cab..fb888cc5c4 100644
--- a/module/doc/lang/zh-cn.php
+++ b/module/doc/lang/zh-cn.php
@@ -49,7 +49,7 @@ $lang->doc->id = 'ID';
$lang->doc->product = '所属' . $lang->productCommon;
$lang->doc->project = "所属{$lang->projectCommon}";
$lang->doc->execution = '所属' . $lang->execution->common;
-$lang->doc->lib = '所属文档库';
+$lang->doc->lib = '所属库';
$lang->doc->module = '所属目录';
$lang->doc->object = '所属对象';
$lang->doc->title = '文档标题';
diff --git a/module/doc/model.php b/module/doc/model.php
index 0b8040d25a..6f25ca9bcf 100644
--- a/module/doc/model.php
+++ b/module/doc/model.php
@@ -954,9 +954,19 @@ class docModel extends model
}
elseif(in_array($type, array('product', 'project', 'execution', 'custom', 'book')))
{
- $queryName = $type . 'Doc';
- $this->config->doc->search['module'] = $queryName;
- $this->config->doc->search['params']['lib']['values'] = array('' => '', $libID => (isset($libs[$libID]) ? $libs[$libID]->name : $libID), 'all' => $this->lang->doclib->all);
+ if(!isset($libs[$libID])) $libs[$libID] = $this->getLibById($libID);
+
+ $libType = $libs[$libID]->type;
+ $libPairs = array('' => '');
+ $queryName = $type . $libType . 'Doc';
+ foreach($libs as $lib)
+ {
+ if($lib->type != $libType) continue;
+ $libPairs[$lib->id] = $lib->name;
+ }
+
+ $this->config->doc->search['module'] = $queryName;
+ $this->config->doc->search['params']['lib']['values'] = $libPairs + array('all' => $this->lang->doclib->all);
unset($this->config->doc->search['fields']['product']);
unset($this->config->doc->search['fields']['execution']);
unset($this->config->doc->search['fields']['module']);
@@ -2795,8 +2805,10 @@ EOT;
*/
public function getDocsBySearch($type, $objectID, $libID, $queryID, $pager)
{
- $queryName = $type . 'DocQuery';
- $queryForm = $type . 'DocForm';
+ $lib = $this->getLibById($libID);
+ $libType = $lib->type;
+ $queryName = $type . $libType . 'DocQuery';
+ $queryForm = $type . $libType . 'DocForm';
if($queryID)
{
$query = $this->loadModel('search')->getQuery($queryID);
@@ -2817,8 +2829,8 @@ EOT;
$libs = $this->getLibsByObject($type, $objectID);
$query = $this->session->$queryName;
- $query = strpos($query, "`lib` = 'all'") === false ? "$query and lib = $libID" : str_replace("`lib` = 'all'", '1', $query);
- $docs = $this->dao->select('*')->from(TABLE_DOC)
+ if(strpos($query, "`lib` = 'all'") !== false) $query = str_replace("`lib` = 'all'", '1', $query);
+ return $this->dao->select('*')->from(TABLE_DOC)
->where('deleted')->eq(0)
->andWhere($query)
->andWhere('lib')->in(array_keys($libs))
@@ -2826,47 +2838,6 @@ EOT;
->orderBy('id_desc')
->page($pager)
->fetchAll('id');
-
- $docContents = $this->dao->select('*')->from(TABLE_DOCCONTENT)->where('doc')->in(array_keys($docs))->orderBy('version,doc')->fetchAll('doc');
-
- $files = $this->dao->select('*')->from(TABLE_FILE)
- ->where('objectType')->eq('doc')
- ->andWhere('objectID')->in(array_keys($docs))
- ->fetchGroup('objectID');
- foreach($docs as $docID => $doc)
- {
- $docs[$docID]->fileSize = 0;
- if(isset($files[$docID]))
- {
- $docContent = $docContents[$docID];
- $fileSize = 0;
- foreach($files[$docID] as $file)
- {
- if(strpos(",{$docContent->files},", ",{$file->id},") === false) continue;
- $fileSize += $file->size;
- }
-
- if($fileSize < 1024)
- {
- $fileSize .= 'B';
- }
- elseif($fileSize < 1024 * 1024)
- {
- $fileSize = round($fileSize / 1024, 2) . 'KB';
- }
- elseif($fileSize < 1024 * 1024 * 1024)
- {
- $fileSize = round($fileSize / 1024 / 1024, 2) . 'MB';
- }
- else
- {
- $fileSize = round($fileSize / 1024 / 1024 / 1024, 2) . 'G';
- }
-
- $docs[$docID]->fileSize = $fileSize;
- }
- }
- return $docs;
}
/**
@@ -2941,10 +2912,11 @@ EOT;
* @param int $moduleID
* @param int $objectID
* @param int $executionID
+ * @param string $browseType bySearch
* @access public
* @return array
*/
- public function getLibTree($libID, $libs, $type, $moduleID, $objectID = 0)
+ public function getLibTree($libID, $libs, $type, $moduleID, $objectID = 0, $browseType = '')
{
if($type == 'project')
{
@@ -2970,7 +2942,7 @@ EOT;
$item->name = $lib->name;
$item->objectType = $type;
$item->objectID = $objectID;
- $item->active = $lib->id == $libID ? 1 : 0;
+ $item->active = $lib->id == $libID && $browseType != 'bySearch' ? 1 : 0;
$item->children = $this->getModuleTree($lib->id, $moduleID, $lib->type == 'api' ? 'api' : 'doc');
$item->children = array_values($item->children);
if(($type == 'project' and $lib->type != 'execution') or $type != 'project')
diff --git a/module/doc/view/doclist.html.php b/module/doc/view/doclist.html.php
new file mode 100644
index 0000000000..457e3abca1
--- /dev/null
+++ b/module/doc/view/doclist.html.php
@@ -0,0 +1,117 @@
+
+ * @package doc
+ * @version $Id$
+ * @link https://www.zentao.net
+ */
+?>
+
+
+
+ doc->noDoc;?>
+ ";
+ $html .= html::a($this->createLink('doc', 'createBasicInfo', "objectType=$type&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html", '', true), " {$lang->doc->create}", '', "class='btn btn-info iframe'");
+ $html .= "";
+ $html .= "
';
+ echo $html;
+ }
+ }
+ ?>
+
+
+
+
+
+
+
+ | doc->id;?> |
+ doc->title;?> |
+ doc->addedByAB;?> |
+ doc->addedDate;?> |
+ doc->editedBy;?> |
+ doc->editedDate;?> |
+ actions;?> |
+
+
+
+
+ collector, ',' . $this->app->user->account . ',') !== false ? 'icon-star text-yellow' : 'icon-star-empty';?>
+ collector, ',' . $this->app->user->account . ',') !== false ? $lang->doc->cancelCollection : $lang->doc->collect;?>
+
+ {$type}) ? $doc->{$type} : 0;?>
+ |
+ createLink('doc', 'objectLibs', "type=$type&objectID=$objectID&libID=$doc->lib&docID=$doc->id"), $doc->id, '', "title='{$doc->id}' data-app='{$this->app->tab}'");
+ }
+ else
+ {
+ echo " {$doc->id}";
+ }
+ ?>
+ |
+
+ createLink('doc', 'objectLibs', "type=$type&objectID=$objectID&libID=$doc->lib&docID=$doc->id"), " " . $doc->title, '', "title='{$doc->title}' data-app='{$this->app->tab}' class='text-primary'");
+ }
+ else
+ {
+ echo " {$doc->title}";
+ }
+ ?>
+
+ id&objectType=doc");?>" title="" class='btn btn-link ajaxCollect'>
+
+ |
+ addedBy);?> |
+ addedDate, 'y-m-d');?> |
+ editedBy);?> |
+ editedDate, 'y-m-d');?> |
+
+
+ id&comment=false", "", '', "title='{$lang->edit}' class='btn btn-link'", true, false)?>
+ id&confirm=no", "", 'hiddenwin', "title='{$lang->delete}' class='btn btn-link'")?>
+
+ |
+
+
+
+
+
+
+
+
+
diff --git a/module/doc/view/tablecontents.html.php b/module/doc/view/tablecontents.html.php
index 3e2a11a6f8..9e4d43ada1 100644
--- a/module/doc/view/tablecontents.html.php
+++ b/module/doc/view/tablecontents.html.php
@@ -11,7 +11,6 @@
*/
?>
-
doc);?>
@@ -73,112 +72,23 @@
-
>
-
-
-
- doc->noDoc;?>
- ";
- $html .= html::a($this->createLink('doc', 'createBasicInfo', "objectType=$type&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html", '', true), " {$lang->doc->create}", '', "class='btn btn-info iframe'");
- $html .= "";
- $html .= "
';
- echo $html;
- }
- }
- ?>
-
-
-
-
-
-
-
- | doc->id;?> |
- doc->title;?> |
- doc->addedByAB;?> |
- doc->addedDate;?> |
- doc->editedBy;?> |
- doc->editedDate;?> |
- actions;?> |
-
-
-
-
- collector, ',' . $this->app->user->account . ',') !== false ? 'icon-star text-yellow' : 'icon-star-empty';?>
- collector, ',' . $this->app->user->account . ',') !== false ? $lang->doc->cancelCollection : $lang->doc->collect;?>
-
- {$type}) ? $doc->{$type} : 0;?>
- |
- createLink('doc', 'objectLibs', "type=$type&objectID=$objectID&libID=$doc->lib&docID=$doc->id"), $doc->id, '', "title='{$doc->id}' data-app='{$this->app->tab}'");
- }
- else
- {
- echo " {$doc->id}";
- }
- ?>
- |
-
- createLink('doc', 'objectLibs', "type=$type&objectID=$objectID&libID=$doc->lib&docID=$doc->id"), " " . $doc->title, '', "title='{$doc->title}' data-app='{$this->app->tab}' class='text-primary'");
- }
- else
- {
- echo " {$doc->title}";
- }
- ?>
-
- id&objectType=doc");?>" title="" class='btn btn-link ajaxCollect'>
-
- |
- addedBy);?> |
- addedDate, 'y-m-d');?> |
- editedBy);?> |
- editedDate, 'y-m-d');?> |
-
-
- id&comment=false", "", '', "title='{$lang->edit}' class='btn btn-link'", true, false)?>
- id&confirm=no", "", 'hiddenwin', "title='{$lang->delete}' class='btn btn-link'")?>
-
- |
-
-
-
-
-
-
-
-
+
+ >
+