diff --git a/module/doc/control.php b/module/doc/control.php
index e3813db046..b6d2bf66e7 100644
--- a/module/doc/control.php
+++ b/module/doc/control.php
@@ -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"), " " . $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"), " " . $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();
}
}
diff --git a/module/doc/css/common.css b/module/doc/css/common.css
index e809dd9fb4..710f7335fd 100644
--- a/module/doc/css/common.css
+++ b/module/doc/css/common.css
@@ -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;}
diff --git a/module/doc/css/objectlibs.css b/module/doc/css/objectlibs.css
index 5c92ebe539..712e87f486 100644
--- a/module/doc/css/objectlibs.css
+++ b/module/doc/css/objectlibs.css
@@ -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;}
diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php
index 8351758fad..7bfd4a5f81 100644
--- a/module/doc/lang/en.php
+++ b/module/doc/lang/en.php
@@ -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';
diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php
index 4214833e83..1b22fa5b93 100644
--- a/module/doc/lang/zh-cn.php
+++ b/module/doc/lang/zh-cn.php
@@ -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 = '附件库';
diff --git a/module/doc/model.php b/module/doc/model.php
index abfa561900..a490dda85b 100644
--- a/module/doc/model.php
+++ b/module/doc/model.php
@@ -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 = "
";
$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 .= "- " . 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]) ? "" : '';
- $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] = "
- " . html::a($link, $branchName, '_self', "id='branch" . (empty($branch) ? "{$id}_0" : $branch) . "'") . "{$childMenu}
";
- }
- $tree .= isset($treeMenu[0]) ? $treeMenu[0] : '';
- }
- if($productNum > 1) $tree = "\n";
- $menu .= $tree;
+ if(!isset($moduleDocs[$doc->module])) $moduleDocs[$doc->module] = array();
+ $moduleDocs[$doc->module][] = $doc;
}
- $menu .= '
';
+ $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] .= '' . html::a(inlink('objectLibs', "type=$type&objectID=$objectID&libID=$rootID&docID={$doc->id}"), $doc->title) . '';
+ }
+ }
+
+ if(empty($treeMenu)) return '';
+
+ $menu = "';
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] .= '' . html::a(inlink('objectLibs', "type=$type&objectID=$objectID&libID=$libID&docID={$doc->id}"), $doc->title) . '';
+ }
+ }
+
+ $li = '' . $module->name . '';
+ if($treeMenu[$module->id])
+ {
+ $li .= '' . $treeMenu[$module->id] . '
';
+ }
+
+ if(!isset($treeMenu[$module->parent])) $treeMenu[$module->parent] = '';
+ $treeMenu[$module->parent] .= 'id] ? ' class="closed"' : '') . '>' . $li . '';
+ }
}
diff --git a/module/doc/view/objectlibs.html.php b/module/doc/view/objectlibs.html.php
index 609c2c1117..9554886ffa 100644
--- a/module/doc/view/objectlibs.html.php
+++ b/module/doc/view/objectlibs.html.php
@@ -15,65 +15,18 @@
- from == 'doc'):?>
-
- cookie->browseType == 'bylist'):?>
-
-
-
-
-
-
-
openApp == 'doc' ? $object->name : $object->name . $lang->doc->common;?>
-
- ", '', "title='{$lang->doc->browseTypeList['grid']}' class='btn btn-icon text-primary'");?>
- ", '', "title='{$lang->doc->browseTypeList['list']}' class='btn btn-icon'");?>
-
-
-
-
-
- $lib):?>
- openApp != 'doc') continue;?>
- doc->custom->objectLibs, 'files') === false && $libID == 'files') continue;?>
- doc->custom->objectLibs, 'customFiles') === false && isset($lib->main) && !$lib->main) continue;?>
-
-
- id");?>
- id");?>
-
-
-
-
-
-
-
- collector, $this->app->user->account) !== false ? " " : '') . $lib->name;?>
- allCount . $lang->doc->item;?>
-
-
- 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;?>
-
-
-
-
" title="" class='btn btn-link ajaxCollect'>
-
- ", '', "title='{$lang->edit}' class='btn btn-link iframe'")?>
- main)) common::printLink('doc', 'deleteLib', "libID=$libID", "
", 'hiddenwin', "title='{$lang->delete}' class='btn btn-link'")?>
- ", '', "title='{$lang->doc->manageType}' class='btn btn-link'")?>
-
-
-
-
-
-
+
+
+
+
+
-
diff --git a/module/doc/view/objectlibsbylist.html.php b/module/doc/view/objectlibsbylist.html.php
deleted file mode 100644
index b31cf5813e..0000000000
--- a/module/doc/view/objectlibsbylist.html.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
from == 'doc' ? $object->name : $object->name . $lang->doc->common;?>
-
- ", '', "title='{$lang->doc->browseTypeList['grid']}' class='btn btn-icon'");?>
- ", '', "title='{$lang->doc->browseTypeList['list']}' class='btn btn-icon text-primary'");?>
-
-
-
-
-
-
-
- | doc->libName;?> |
- doc->num;?> |
- actions;?> |
-
-
-
- $lib):?>
- from != 'doc') continue;?>
- doc->custom->objectLibs, 'files') === false && $libID == 'files') continue;?>
- doc->custom->objectLibs, 'customFiles') === false && isset($lib->main) && !$lib->main) continue;?>
-
- from");?>
- id");?>
- id&from=$this->from");?>
-
- | name);?> |
- allCount . $lang->doc->item;?> |
-
-
- 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;?>
-
- " title="" class='btn btn-link ajaxCollect'>
-
- ", '', "title='{$lang->edit}' class='btn btn-link iframe'")?>
- main)) common::printLink('doc', 'deleteLib', "libID=$libID", "", 'hiddenwin', "title='{$lang->delete}' class='btn btn-link'")?>
- from", "", '', "title='{$lang->doc->manageType}' class='btn btn-link'")?>
-
- |
-
-
-
-
-
-
-
diff --git a/module/doc/view/side.html.php b/module/doc/view/side.html.php
index 816751b59d..bc43b010a0 100644
--- a/module/doc/view/side.html.php
+++ b/module/doc/view/side.html.php
@@ -18,16 +18,16 @@ $sideWidth = common::checkNotCN() ? '270' : '238';
-
+
doc->noModule;?>
- doc->manageType, '', "class='btn btn-info btn-wide'");?>
- doc->editLib, '', "class='btn btn-info btn-wide'");?>
- doc->deleteLib, '', "class='btn btn-info btn-wide'");?>
+ doc->manageType, '', "class='btn btn-info btn-wide'");?>
+ doc->editLib, '', "class='btn btn-info btn-wide'");?>
+ doc->deleteLib, '', "class='btn btn-info btn-wide'");?>
diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php
index 26c147b698..3c0bf9c768 100644
--- a/module/group/lang/resource.php
+++ b/module/group/lang/resource.php
@@ -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';
diff --git a/module/tree/control.php b/module/tree/control.php
index 6a03bac340..4623d76ccb 100644
--- a/module/tree/control.php
+++ b/module/tree/control.php
@@ -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;