* Ajdust doc module.

This commit is contained in:
zhujinyong
2021-04-02 14:31:30 +08:00
parent 0beaa1a968
commit fd047654f1
11 changed files with 123 additions and 181 deletions
+33 -6
View File
@@ -869,12 +869,13 @@ class doc extends control
*
* @param string $type
* @param int $objectID projectID|productID
* @param int $libID
* @param int $docID
* @access public
* @return void
*/
public function objectLibs($type, $objectID = 0, $libID = 0)
public function objectLibs($type, $objectID = 0, $libID = 0, $docID = 0)
{
// setcookie('from', $from, $this->config->cookieLife, $this->config->webRoot, '', false, true);
$this->session->set('docList', $this->app->getURI(true), 'doc');
if($type == 'product')
@@ -884,7 +885,9 @@ class doc extends control
$table = TABLE_PRODUCT;
$libs = $this->doc->getLibsByObject('product', $objectID);
$this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs, $libID == 0 ? key($libs) : $libID);
if($libID == 0) $libID = key($libs);
$this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs, $libID);
$this->app->rawMethod = 'product';
}
@@ -895,7 +898,9 @@ class doc extends control
$table = TABLE_PROJECT;
$libs = $this->doc->getLibsByObject('project', $objectID);
$this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs, $libID == 0 ? key($libs) : $libID);
if($libID == 0) $libID = key($libs);
$this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs, $libID);
$this->app->rawMethod = 'project';
}
@@ -912,20 +917,42 @@ class doc extends control
$actionURL = $this->createLink('doc', 'browse', "lib=0&browseType=bySearch&queryID=myQueryID");
$this->doc->buildSearchForm(0, array(), 0, $actionURL, 'objectLibs');
$this->lang->TRActions = common::hasPriv('doc', 'createLib') ? html::a(helper::createLink('doc', 'createLib', "type=$type&objectID=$objectID"), "<i class='icon icon-plus'></i> " . $this->lang->doc->createlib, '', "class='btn btn-secondary iframe' data-width='70%'") : '';
$this->lang->TRActions = common::hasPriv('doc', 'createLib') ? html::a(helper::createLink('doc', 'createLib', "type=$type&objectID=$objectID"), "<i class='icon icon-plus'></i> " . $this->lang->doc->createLib, '', "class='btn btn-secondary iframe' data-width='70%'") : '';
$this->lang->TRActions .= common::hasPriv('doc', 'create') ? $this->doc->buildCreateButton4Doc($type, $objectID, $libID) : '';
$moduleTree = $this->doc->getTreeMenu($type, $objectID, $libID, 0, $docID);
/* Get doc. */
if($docID)
{
$doc = $this->doc->getById($docID, 0, true);
if(!$doc) die(js::error($this->lang->notFound) . js::locate('back'));
if($doc->contentType == 'markdown')
{
$hyperdown = $this->app->loadClass('hyperdown');
$doc->content = $hyperdown->makeHtml($doc->content);
$doc->digest = $hyperdown->makeHtml($doc->digest);
}
}
$this->view->customObjectLibs = $customObjectLibs;
$this->view->showLibs = $this->config->doc->custom->objectLibs;
$this->view->title = $object->name;
$this->view->position[] = $object->name;
$this->view->docID = $docID;
$this->view->doc = $docID ? $doc : '';
$this->view->type = $type;
$this->view->object = $object;
$this->view->libID = $libID;
$this->view->lib = $libs[$libID];
$this->view->libs = $this->doc->getLibsByObject($type, $objectID);
$this->view->moduleTree = $this->doc->getTreeMenu($type, $objectID, 0);
$this->view->moduleTree = $moduleTree;
$this->view->canBeChanged = common::canModify($type, $object); // Determines whether an object is editable.
$this->view->actions = $docID ? $this->action->getList('doc', $docID) : array();
$this->view->users = $this->user->getPairs('noclosed,noletter');
$this->display();
}
}
+1 -1
View File
@@ -63,7 +63,7 @@
.main-col > .panel > .panel-body {padding: 5px 10px;}
.main-col .panel-title a.active {color: #0c64eb;}
.side-col > .cell {overflow: hidden auto; padding: 0; position: relative;}
.side-col > .cell {overflow: hidden auto; position: relative;}
.side-col > .cell > header {position: absolute; top: 10px; right: 10px; left: 10px;}
.side-col > .cell > header > .c-sm {padding-right: 20px; width: 60px;}
.side-col .docsTree {position: absolute; top: 53px; left: 0; right: 0; bottom: 0; overflow: auto; padding: 0 10px 10px;}
+2 -1
View File
@@ -6,4 +6,5 @@
#dropMenu .table-col .list-group {padding-top: 10px;}
.main-col .block-files .panel-heading {padding-right: 20px;}
.main-col .block-files .panel-heading .panel-title {height: 35px; line-height: 30px;}
.side-col .action a {margin-bottom: 3px;}
.side-col .action a {margin: 0 auto 3px; display: block; max-width: 200px;}
.side-col .tips {padding: 0 10px;}
+1 -1
View File
@@ -90,7 +90,7 @@ $lang->doc->libName = 'Document Library';
$lang->doc->libType = 'Category';
$lang->doc->custom = 'Custom Document Library';
$lang->doc->customAB = 'Custom Doc Lib';
$lang->doc->createlib = 'Create Document Library';
$lang->doc->createLib = 'Create Document Library';
$lang->doc->allLibs = 'Library List';
$lang->doc->objectLibs = "{$lang->productCommon}/{$lang->executionCommon} Libraries";
$lang->doc->showFiles = 'Attachments';
+1 -1
View File
@@ -90,7 +90,7 @@ $lang->doc->libName = '文档库名称';
$lang->doc->libType = '文档库类型';
$lang->doc->custom = '自定义文档库';
$lang->doc->customAB = '自定义库';
$lang->doc->createlib = '创建文档库';
$lang->doc->createLib = '创建文档库';
$lang->doc->allLibs = '文档库列表';
$lang->doc->objectLibs = "{$lang->productCommon}/{$lang->executionCommon}库列表";
$lang->doc->showFiles = '附件库';
+71 -58
View File
@@ -1814,79 +1814,92 @@ EOF;
/**
* Get doc tree menu.
*
* @param string $rootID
* @param string $type
* @param int $objectID
* @param int $rootID
* @param int $startModule
* @access public
* @return string
*/
public function getTreeMenu($type, $rootID, $startModule = 0)
public function getTreeMenu($type, $objectID, $rootID, $startModule = 0, & $docID = 0)
{
return '';
$extra['projectID'] = $rootID;
$menu = "<ul id='modules' class='tree' data-ride='tree' data-name='tree-story'>";
$startModulePath = '';
if($startModule > 0)
{
$startModule = $this->getById($startModule);
$startModule = $this->tree->getById($startModule);
if($startModule) $startModulePath = $startModule->path . '%';
}
$executionModules = $this->getTaskTreeModules($rootID, true);
$executionBranches = $this->dao->select('DISTINCT t2.branch')->from(TABLE_PROJECTSTORY)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->where('t1.project')->eq($rootID)
->andWhere('t2.deleted')->eq(0)
->fetchPairs();
/* Get module according to product. */
$products = $this->loadModel('product')->getProductPairsByProject($rootID);
$branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products));
$productNum = count($products);
foreach($products as $id => $product)
$docs = $this->dao->select('*')->from(TABLE_DOC)->where('lib')->eq($rootID)->andWhere('deleted')->eq(0)->fetchAll();
$moduleDocs = array();
foreach($docs as $doc)
{
$projectProductLink = helper::createLink('projectstory', 'story', "projectID=$rootID&productID=$id");
$executionProductLink = helper::createLink('execution', 'story', "executionID=$rootID&ordery=&status=byProduct&praram=$id");
$link = $this->app->rawModule == 'projectstory' ? $projectProductLink : $executionProductLink;
if($productNum > 1) $menu .= "<li>" . html::a($link, $product, '_self', "id='product$id'");
/* tree menu. */
$tree = '';
if(empty($branchGroups[$id])) $branchGroups[$id]['0'] = '';
foreach($branchGroups[$id] as $branch => $branchName)
{
$treeMenu = array();
$query = $this->dao->select('*')->from(TABLE_MODULE)
->where('root')->eq((int)$id)
->andWhere('type')->eq('story')
->beginIF(count($branchGroups[$id]) > 1)->andWhere('branch')->eq($branch)->fi()
->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi()
->andWhere('deleted')->eq(0)
->orderBy('grade desc, branch, `order`, type')
->get();
$stmt = $this->dbh->query($query);
while($module = $stmt->fetch())
{
/* If not manage, ignore unused modules. */
if(isset($executionModules[$module->id]) and $this->app->rawModule == 'execution') $this->buildTree($treeMenu, $module, 'task', $userFunc, $extra);
if($this->app->rawModule == 'projectstory') $this->buildTree($treeMenu, $module, 'task', $userFunc, $extra);
}
if((isset($treeMenu[0]) and $branch) or isset($executionBranches[$branch]))
{
$childMenu = isset($treeMenu[0]) ? "<ul>{$treeMenu[0]}</ul>" : '';
$projectBranchLink = helper::createLink('projectstory', 'story', "projectID=$rootID&productID=$id&branch=" . (empty($branch) ? 0 : $branch) . "&browseType=byBranch");
$executionBranchLink = helper::createLink('execution', 'story', "executionID=$rootID&ordery=&status=byBranch&praram=" . (empty($branch) ? "{$id},0" : $branch));
$link = $this->app->rawModule == 'projectstory' ? $projectBranchLink : $executionBranchLink;
if($branchName) $treeMenu[0] = "<li>" . html::a($link, $branchName, '_self', "id='branch" . (empty($branch) ? "{$id}_0" : $branch) . "'") . "{$childMenu}</li>";
}
$tree .= isset($treeMenu[0]) ? $treeMenu[0] : '';
}
if($productNum > 1) $tree = "<ul>" . $tree . "</ul>\n</li>";
$menu .= $tree;
if(!isset($moduleDocs[$doc->module])) $moduleDocs[$doc->module] = array();
$moduleDocs[$doc->module][] = $doc;
}
$menu .= '</ul>';
$treeMenu = array();
$query = $this->dao->select('*')->from(TABLE_MODULE)
->where('root')->eq((int)$rootID)
->andWhere('type')->eq('doc')
->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi()
->andWhere('deleted')->eq(0)
->orderBy('grade desc, `order`')
->get();
$stmt = $this->dbh->query($query);
while($module = $stmt->fetch())
{
$this->buildTree($treeMenu, $type, $objectID, $rootID, $module, $moduleDocs, $docID);
}
if(isset($moduleDocs[0]))
{
foreach($moduleDocs[0] as $doc)
{
if(!$docID) $docID = $doc->id;
$treeMenu[0] .= '<li>' . html::a(inlink('objectLibs', "type=$type&objectID=$objectID&libID=$rootID&docID={$doc->id}"), $doc->title) . '</li>';
}
}
if(empty($treeMenu)) return '';
$menu = "<ul id='modules' class='tree' data-ride='tree' data-name='tree-lib'>" . $treeMenu[0] . '</ul>';
return $menu;
}
/**
* Build doc tree menu.
*
* @param pointer $treeMenu
* @param string $type
* @param int $objectID
* @param int $libID
* @param object $module
* @param array $moduleDocs
* @param int $docID
* @access public
* @return string
*/
private function buildTree(& $treeMenu, $type, $objectID, $libID, $module, $moduleDocs, & $docID)
{
if(!isset($treeMenu[$module->id])) $treeMenu[$module->id] = '';
if(isset($moduleDocs[$module->id]))
{
foreach($moduleDocs[$module->id] as $doc)
{
if(!$docID) $docID = $doc->id;
$treeMenu[$module->id] .= '<li>' . html::a(inlink('objectLibs', "type=$type&objectID=$objectID&libID=$libID&docID={$doc->id}"), $doc->title) . '</li>';
}
}
$li = '<a>' . $module->name . '</a>';
if($treeMenu[$module->id])
{
$li .= '<ul>' . $treeMenu[$module->id] . '</ul>';
}
if(!isset($treeMenu[$module->parent])) $treeMenu[$module->parent] = '';
$treeMenu[$module->parent] .= '<li' . ($treeMenu[$module->id] ? ' class="closed"' : '') . '>' . $li . '</li>';
}
}
+7 -54
View File
@@ -15,65 +15,18 @@
<style>.panel-body{min-height: 180px}</style>
<?php endif;?>
<div class="fade main-row <?php if($app->openApp == 'doc') echo 'split-row';?>" id="mainRow">
<?php if($this->from == 'doc'):?>
<?php include './side.html.php';?>
<?php endif;?>
<?php if($this->cookie->browseType == 'bylist'):?>
<?php include dirname(__FILE__) . '/objectlibsbylist.html.php';?>
<?php else:?>
<div class="main-col" data-min-width="400">
<div class="cell" id="queryBox" data-module='doc'></div>
<div class="panel block-files block-sm no-margin">
<div class="panel-heading">
<div class="panel-title font-normal">
<i class="icon icon-folder-open-o text-muted"></i> <?php echo $app->openApp == 'doc' ? $object->name : $object->name . $lang->doc->common;?>
<div class="btn-group pull-right">
<?php echo html::a('javascript:setBrowseType("bygrid")', "<i class='icon icon-cards-view'></i>", '', "title='{$lang->doc->browseTypeList['grid']}' class='btn btn-icon text-primary'");?>
<?php echo html::a('javascript:setBrowseType("bylist")', "<i class='icon icon-bars'></i>", '', "title='{$lang->doc->browseTypeList['list']}' class='btn btn-icon'");?>
</div>
</div>
</div>
<div class='panel-body'>
<div class="row row-grid files-grid" data-size="300">
<?php foreach($libs as $libID => $lib):?>
<?php if($libID == 'execution' and $app->openApp != 'doc') continue;?>
<?php if(strpos($config->doc->custom->objectLibs, 'files') === false && $libID == 'files') continue;?>
<?php if(strpos($config->doc->custom->objectLibs, 'customFiles') === false && isset($lib->main) && !$lib->main) continue;?>
<?php $libLink = inlink('browse', "libID=$libID&browseType=all&param=0&orderBy=id_desc");?>
<?php if($libID == 'execution') $libLink = inlink('allLibs', "type=execution&product=$object->id");?>
<?php if($libID == 'files') $libLink = inlink('showFiles', "type=$type&objectID=$object->id");?>
<?php $icon = 'icon-folder text-yellow';?>
<?php if($libID == 'files') $icon = 'icon-paper-clip text-brown';?>
<div class="col">
<a class="file" href="<?php echo $libLink;?>">
<i class="file-icon icon <?php echo $icon;?>"></i>
<div class="file-name"><?php echo ($libID != 'execution' && $libID != 'files' && strpos($lib->collector, $this->app->user->account) !== false ? "<i class='icon icon-star text-yellow'></i> " : '') . $lib->name;?></div>
<div class="text-primary file-info"><?php echo $lib->allCount . $lang->doc->item;?></div>
</a>
<?php if($libID != 'execution' and $libID != 'files'):?>
<?php $star = strpos($lib->collector, ',' . $this->app->user->account . ',') !== false ? 'icon-star text-yellow' : 'icon-star-empty';?>
<?php $collectTitle = strpos($lib->collector, ',' . $this->app->user->account . ',') !== false ? $lang->doc->cancelCollection : $lang->doc->collect;?>
<div class="actions">
<?php if($canBeChanged):?>
<?php if(common::hasPriv('doc', 'collect')):?>
<a data-url="<?php echo $this->createLink('doc', 'collect', "objectID=$libID&objectType=doclib");?>" title="<?php echo $collectTitle;?>" class='btn btn-link ajaxCollect'><i class='icon <?php echo $star;?>'></i></a>
<?php endif;?>
<?php common::printLink('doc', 'editLib', "libID=$libID", "<i class='icon icon-edit'></i>", '', "title='{$lang->edit}' class='btn btn-link iframe'")?>
<?php if(empty($lib->main)) common::printLink('doc', 'deleteLib', "libID=$libID", "<i class='icon icon-trash'></i>", 'hiddenwin', "title='{$lang->delete}' class='btn btn-link'")?>
<?php common::printLink('tree', 'browse', "rootID=$libID&viewType=doc&currentModuleID=0&branch=0", "<i class='icon icon-cog'></i>", '', "title='{$lang->doc->manageType}' class='btn btn-link'")?>
<?php endif;?>
</div>
<?php endif;?>
</div>
<?php endforeach;?>
</div>
<?php if($docID):?>
<?php include './content.html.php';?>
<?php else:?>
<div class="cell">
<div class="detail no-padding">
<?php echo $lang->doc->noDoc;?>
</div>
</div>
<?php endif;?>
</div>
<?php endif;?>
</div>
<?php js::set('type', 'doc');?>
<?php include '../../common/view/footer.html.php';?>
-52
View File
@@ -1,52 +0,0 @@
<div class="main-col" data-min-width="400">
<div class="cell" id="queryBox" data-module='doc'></div>
<div class="panel block-files block-sm no-margin">
<div class="panel-heading">
<div class="panel-title font-normal">
<i class="icon icon-folder-open-o text-muted"></i> <?php echo $this->from == 'doc' ? $object->name : $object->name . $lang->doc->common;?>
<div class="btn-group pull-right">
<?php echo html::a('javascript:setBrowseType("bygrid")', "<i class='icon icon-cards-view'></i>", '', "title='{$lang->doc->browseTypeList['grid']}' class='btn btn-icon'");?>
<?php echo html::a('javascript:setBrowseType("bylist")', "<i class='icon icon-bars'></i>", '', "title='{$lang->doc->browseTypeList['list']}' class='btn btn-icon text-primary'");?>
</div>
</div>
</div>
<div class='panel-body'>
<table class="table table-borderless table-hover table-files table-fixed no-margin">
<thead>
<tr>
<th class="c-name"><?php echo $lang->doc->libName;?></th>
<th class="c-num"><?php echo $lang->doc->num;?></th>
<th class="w-90px text-center"><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
<?php foreach($libs as $libID => $lib):?>
<?php if($libID == 'execution' and $this->from != 'doc') continue;?>
<?php if(strpos($config->doc->custom->objectLibs, 'files') === false && $libID == 'files') continue;?>
<?php if(strpos($config->doc->custom->objectLibs, 'customFiles') === false && isset($lib->main) && !$lib->main) continue;?>
<?php $libLink = inlink('browse', "libID=$libID&browseType=all&param=0&orderBy=id_desc&from=$this->from");?>
<?php if($libID == 'execution') $libLink = inlink('allLibs', "type=execution&product=$object->id");?>
<?php if($libID == 'files') $libLink = inlink('showFiles', "type=$type&objectID=$object->id&from=$this->from");?>
<tr>
<td class="c-name"><?php echo html::a($libLink, $lib->name);?></td>
<td class="c-num"><?php echo $lib->allCount . $lang->doc->item;?></td>
<td class="c-actions">
<?php if($canBeChanged and $libID != 'execution' and $libID != 'files'):?>
<?php $star = strpos($lib->collector, ',' . $this->app->user->account . ',') !== false ? 'icon-star text-yellow' : 'icon-star-empty';?>
<?php $collectTitle = strpos($lib->collector, ',' . $this->app->user->account . ',') !== false ? $lang->doc->cancelCollection : $lang->doc->collect;?>
<?php if(common::hasPriv('doc', 'collect')):?>
<a data-url="<?php echo $this->createLink('doc', 'collect', "objectID=$libID&objectType=doclib");?>" title="<?php echo $collectTitle;?>" class='btn btn-link ajaxCollect'><i class='icon <?php echo $star;?>'></i></a>
<?php endif;?>
<?php common::printLink('doc', 'editLib', "libID=$libID", "<i class='icon icon-edit'></i>", '', "title='{$lang->edit}' class='btn btn-link iframe'")?>
<?php if(empty($lib->main)) common::printLink('doc', 'deleteLib', "libID=$libID", "<i class='icon icon-trash'></i>", 'hiddenwin', "title='{$lang->delete}' class='btn btn-link'")?>
<?php common::printLink('tree', 'browse', "rootID=$libID&viewType=doc&currentModuleID=0&branch=0&from=$this->from", "<i class='icon icon-cog'></i>", '', "title='{$lang->doc->manageType}' class='btn btn-link'")?>
<?php endif;?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</div>
</div>
+4 -4
View File
@@ -18,16 +18,16 @@ $sideWidth = common::checkNotCN() ? '270' : '238';
<div class="cell">
<?php if(!$moduleTree):?>
<hr class="space">
<div class="text-center text-muted">
<div class="text-center text-muted tips">
<?php echo $lang->doc->noModule;?>
</div>
<hr class="space">
<?php endif;?>
<?php echo $moduleTree;?>
<div class="text-center action">
<?php common::printLink('tree', 'browse', "rootID=0&view=story", $lang->doc->manageType, '', "class='btn btn-info btn-wide'");?>
<?php common::printLink('tree', 'browse', "rootID=0&view=story", $lang->doc->editLib, '', "class='btn btn-info btn-wide'");?>
<?php common::printLink('tree', 'browse', "rootID=0&view=story", $lang->doc->deleteLib, '', "class='btn btn-info btn-wide'");?>
<?php common::printLink('tree', 'browse', "rootID=$libID&view=doc", $lang->doc->manageType, '', "class='btn btn-info btn-wide'");?>
<?php common::printLink('tree', 'browse', "rootID=0&view=doc", $lang->doc->editLib, '', "class='btn btn-info btn-wide'");?>
<?php common::printLink('tree', 'browse', "rootID=0&view=doc", $lang->doc->deleteLib, '', "class='btn btn-info btn-wide'");?>
<hr class="space-sm" />
</div>
</div>
+2 -2
View File
@@ -1011,8 +1011,8 @@ $lang->job->methodOrder[25] = 'exec';
$lang->resource->doc = new stdclass();
$lang->resource->doc->index = 'index';
$lang->resource->doc->browse = 'browse';
$lang->resource->doc->createlib = 'createlib';
$lang->resource->doc->editlib = 'editlib';
$lang->resource->doc->createLib = 'createLib';
$lang->resource->doc->editLib = 'editLib';
$lang->resource->doc->deleteLib = 'deleteLib';
$lang->resource->doc->create = 'create';
$lang->resource->doc->view = 'view';
+1 -1
View File
@@ -164,7 +164,7 @@ class tree extends control
}
if($from == 'doc') $this->lang->navGroup->doc = 'doc';
$type = $lib->product ? 'product' : ($lib->execution ? 'project' : 'custom');
$type = $lib->product ? 'product' : ($lib->project ? 'project' : ($lib->execution ? 'execution' : 'custom'));
$this->lang->tree->menu = $this->lang->doc->menu;
$this->lang->tree->menuOrder = $this->lang->doc->menuOrder;