diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index f31f2a75aa..4731e73e0b 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -304,10 +304,7 @@ $lang->caselib->menu->caselib = array('link' => '用例库|testsuite|library', /* 文档视图菜单设置。*/ $lang->doc = new stdclass(); $lang->doc->menu = new stdclass(); - -//$lang->doc->menu->list = array('link' => '%s', 'fixed' => true); -//$lang->doc->menu->crumb = array('link' => '%s', 'fixed' => true); -//$lang->doc->menu->create = array('link' => ' 添加文档库|doc|createLib', 'float' => 'right'); +//$lang->doc->menu->createLib = array('link' => ' 添加文件夹|doc|createLib', 'float' => 'right'); /* 统计视图菜单设置。*/ $lang->report = new stdclass(); diff --git a/module/doc/control.php b/module/doc/control.php index 1b0874c19a..e0a3148b46 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -37,6 +37,8 @@ class doc extends control */ public function index() { + $this->doc->setMenu(); + $products = $this->doc->getLimitLibs('product'); $projects = $this->doc->getLimitLibs('project'); $customLibs = $this->doc->getLimitLibs('custom'); @@ -90,20 +92,22 @@ class doc extends control $queryID = ($browseType == 'bysearch') ? (int)$param : 0; $moduleID = ($browseType == 'bymodule' or $browseType == 'bymenu') ? (int)$param : 0; - $type = 'custom'; + $type = ''; + $productID = 0; + $projectID = 0; if($libID) { - $lib = $this->doc->getLibByID($libID); - if($lib->product or $lib->project) $type = $lib->product ? 'product' : 'project'; + $type = 'custom'; + $lib = $this->doc->getLibByID($libID); + if($lib->product or $lib->project) + { + $type = $lib->product ? 'product' : 'project'; + $productID = $lib->product; + $projectID = $lib->project; + } } - if(empty($libID)) $type = 'product'; $this->libs = $this->doc->getLibs($type); - if(empty($libID)) - { - $libID = key($this->libs); - $lib = $this->dao->select('*')->from(TABLE_DOCLIB)->where('id')->eq($libID)->orderBy('id')->fetch(); - } /* According the from, set menus. */ if($from == 'product') @@ -122,20 +126,21 @@ class doc extends control } else { - $this->doc->setMenu($libID, $moduleID); + $menuType = (!$type && in_array($browseType, array_keys($this->lang->doc->fastMenuList))) ? $browseType : $type; + $this->doc->setMenu($menuType, $libID, $moduleID, $productID, $projectID); } $this->session->set('docList', $this->app->getURI(true)); /* Set header and position. */ - $this->view->title = $this->lang->doc->common . $this->lang->colon . $this->libs[$libID]; - $this->view->position[] = $this->libs[$libID]; + $this->view->title = $this->lang->doc->common . ($libID ? $this->lang->colon . $this->libs[$libID] : ''); + $this->view->position[] = $libID ? $this->libs[$libID] : ''; /* Load pager. */ $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); /* Append id for secend sort. */ - if($browseType == 'bymenu' and strpos('editeddate_desc,addeddate_desc,visiteddate_desc', strtolower($orderBy)) === false) $orderBy = 'title_asc'; + if($browseType == 'bymenu' and strpos('editeddate_desc,addeddate_desc', strtolower($orderBy)) === false) $orderBy = 'title_asc'; $sort = $this->loadModel('common')->appendOrder($orderBy); /* Get docs by browse type. */ @@ -166,7 +171,7 @@ class doc extends control } $this->view->libID = $libID; - $this->view->libName = $this->libs[$libID]; + $this->view->libName = $libID ? $this->libs[$libID] : ''; $this->view->moduleID = $moduleID; $this->view->docs = $docs; $this->view->pager = $pager; @@ -308,8 +313,8 @@ class doc extends control die(js::locate($link, 'parent')); } - $lib = $this->doc->getLibByID($libID); - $type = $lib->product ? 'product' : ($lib->project ? 'project' : 'custom'); + $lib = $this->doc->getLibByID($libID); + $type = $lib->product ? 'product' : ($lib->project ? 'project' : 'custom'); /* According the from, set menus. */ if($this->from == 'product') @@ -328,7 +333,7 @@ class doc extends control } else { - $this->doc->setMenu($libID, $moduleID); + $this->doc->setMenu($type, $libID, $moduleID, $lib->product, $lib->project); } $this->view->title = $lib->name . $this->lang->colon . $this->lang->doc->create; @@ -382,7 +387,7 @@ class doc extends control $lib = $this->doc->getLibByID($libID); $type = $lib->product ? 'product' : ($lib->project ? 'project' : 'custom'); - $this->doc->setMenu($libID, $doc->module); + $this->doc->setMenu($type, $libID, $doc->module, $lib->product, $lib->project); $this->view->title = $lib->name . $this->lang->colon . $this->lang->doc->edit; $this->view->position[] = html::a($this->createLink('doc', 'browse', "libID=$libID"), $lib->name); @@ -421,7 +426,7 @@ class doc extends control $type = $lib->product ? 'product' : ($lib->project ? 'project' : 'custom'); /* Set menu. */ - $this->doc->setMenu($doc->lib, $doc->module); + $this->doc->setMenu($type, $doc->lib, $doc->module, $lib->product, $lib->project); /* Update visitedDate and views for current doc.*/ $this->doc->updateVisitData($docID); @@ -527,6 +532,7 @@ class doc extends control if(empty($customMenus)) { if($type == 'remove') die(js::reload('parent')); + $customMenus = array(); $i = 0; foreach($this->lang->doc->menu as $name => $item) { @@ -539,6 +545,7 @@ class doc extends control } } + $customMenus = (array)$customMenus; foreach($customMenus as $i => $customMenu) { if(isset($customMenu->name) and $customMenu->name == "custom{$libID}") unset($customMenus[$i]); @@ -587,7 +594,7 @@ class doc extends control $this->view->title = $libName; $this->view->position[] = $libName; - $this->doc->setMenu($libID = 0, $moduleID = 0, $crumb); + $this->doc->setMenu($type, $libID = 0, $moduleID = 0, $productID = 0, $projectID = 0, $crumb); /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -648,19 +655,23 @@ class doc extends control $crumb .= html::a(inlink('objectLibs', "type=$type&objectID=$objectID"), $object->name); $crumb .= $this->lang->doc->separator . ' ' . $this->lang->doclib->files; + $productID = 0; + $projectID = 0; if($type == 'product') { + $productID = $objectID; $lib = $this->product->getById($objectID); if(!$this->product->checkPriv($lib)) $this->accessDenied(); } if($type == 'project') { + $projectID = $objectID; $lib = $this->project->getById($objectID); if(!$this->project->checkPriv($lib)) $this->accessDenied(); } - $this->doc->setMenu($libID = 0, $moduleID = 0, $crumb); + $this->doc->setMenu($type, $libID = 0, $moduleID = 0, $productID, $projectID, $crumb); } /* Load pager. */ @@ -734,7 +745,9 @@ class doc extends control $crumb = html::a(inlink('allLibs', "type=$type"), $type == 'product' ? $this->lang->productCommon : $this->lang->projectCommon) . $this->lang->doc->separator; if($this->productID and $type == 'project') $crumb = $this->doc->getProductCrumb($this->productID, $objectID); $crumb .= html::a(inlink('objectLibs', "type=$type&objectID=$objectID"), $object->name); - $this->doc->setMenu($libID = 0, $moduleID = 0, $crumb); + $productID = $type == 'product' ? $objectID : 0; + $projectID = $type == 'project' ? $objectID : 0; + $this->doc->setMenu($type, $libID = 0, $moduleID = 0, $productID, $projectID, $crumb); } $this->view->title = $object->name; diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index 08cd519fd3..f5cc00cb29 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -58,7 +58,7 @@ $lang->doc->myDoc = '我的文档'; $lang->doc->myCollection = '我的收藏'; /* 方法列表。*/ -$lang->doc->index = '首页'; +$lang->doc->index = '文档主页'; $lang->doc->create = '创建文档'; $lang->doc->edit = '编辑文档'; $lang->doc->delete = '删除文档'; @@ -119,12 +119,12 @@ $lang->doc->browseTypeList['menu'] = '目录'; $lang->doc->browseTypeList['tree'] = '树状图'; $lang->doc->browseTypeList['card'] = '卡片'; -$lang->doc->fastMenuList['editeddate'] = '最近更新'; +$lang->doc->fastMenuList['byediteddate'] = '最近更新'; $lang->doc->fastMenuList['visiteddate'] = '最近访问'; $lang->doc->fastMenuList['openedbyme'] = '我的文档'; $lang->doc->fastMenuList['collectedbyme'] = '我的收藏'; -$lang->doc->fastMenuIconList['editeddate'] = 'icon-folder-upload'; +$lang->doc->fastMenuIconList['byediteddate'] = 'icon-folder-upload'; $lang->doc->fastMenuIconList['visiteddate'] = 'icon-folder-move'; $lang->doc->fastMenuIconList['openedbyme'] = 'icon-folder-account'; $lang->doc->fastMenuIconList['collectedbyme'] = 'icon-folder-star'; diff --git a/module/doc/model.php b/module/doc/model.php index 8029ca21bd..ad5329e3bc 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -22,60 +22,162 @@ class docModel extends model * @access public * @return void */ - public function setMenu($libID = 0, $moduleID = 0, $crumb = '') + public function setMenu($type = '', $libID = 0, $moduleID = 0, $productID = 0, $projectID = 0, $crumb = '') { - $customMenuKey = $this->config->global->flow . '_doc'; - if(isset($this->config->customMenu->{$customMenuKey})) + $selectHtml = "
"; + $selectHtml .= html::a(helper::createLink('doc', 'index'), $this->lang->doc->index, '', "class='btn'"); + $selectHtml .= '
'; + + if($type) { - $customMenu = json_decode($this->config->customMenu->{$customMenuKey}, true); - $menuLibIdList = array(); - foreach($customMenu as $i => $menu) + $mainLib = in_array($type, array_keys($this->lang->doc->fastMenuList)) ? $this->lang->doc->fastMenuList[$type] : ''; + + if($libID) { - if(strpos($menu['name'], 'custom') === 0) + $lib = $this->getLibById($libID); + if($this->checkPriv($lib)) { - $menuLibID = (int)substr($menu['name'], 6); - if($menuLibID) $menuLibIdList[$i] = $menuLibID; + $type = $lib->product ? 'product' : 'custom'; + $type = $lib->project ? 'project' : $type; } } - $productIdList = array(); - $projectIdList = array(); - if($menuLibIdList) + $mainLib = $type == 'custom' ? $this->lang->doc->customAB : $mainLib; + $mainLib = $type == 'product' ? $this->lang->productCommon : $mainLib; + $mainLib = $type == 'project' ? $this->lang->projectCommon : $mainLib; + + $selectHtml .= "
"; + $selectHtml .= "
"; + $selectHtml .= "" . $mainLib . " "; + $selectHtml .= "
'; + + if(strpos('product,project,custom', $type) !== false) { - $lib = $libs[$menuLibID]; - $libName = ''; - if($lib->product) $libName = isset($products[$lib->product]) ? '[' . $products[$lib->product] . ']' : ''; - if($lib->project) $libName = isset($projects[$lib->project]) ? '[' . $projects[$lib->project] . ']' : ''; - $libName .= $lib->name; - $customMenu[$i]['link'] = "{$libName}|doc|browse|libID={$menuLibID}"; + $allLibGroups = $this->getAllLibGroups(); + $currentGroups = $allLibGroups[$type]; + + if($type == 'custom') $currentLib = $libID ? $libID : key($currentGroups); + if($type == 'product') $currentLib = $productID ? $productID : key($currentGroups); + if($type == 'project') $currentLib = $projectID ? $projectID : key($currentGroups); + + $selectHtml .= "
"; + $selectHtml .= "
"; + $selectHtml .= '' . (is_array($currentGroups[$currentLib]) ? $currentGroups[$currentLib]['name'] : $currentGroups[$currentLib]) . ' '; + $selectHtml .='
'; } - $this->config->customMenu->{$customMenuKey} = json_encode($customMenu); + + $actions = ''; + $customMenuKey = $this->config->global->flow . '_doc'; + if(isset($this->config->customMenu->{$customMenuKey})) + { + $customMenu = json_decode($this->config->customMenu->{$customMenuKey}, true); + $menuLibIdList = array(); + foreach($customMenu as $i => $menu) + { + if(strpos($menu['name'], 'custom') === 0) + { + $menuLibID = (int)substr($menu['name'], 6); + if($menuLibID) $menuLibIdList[$i] = $menuLibID; + } + } + + $productIdList = array(); + $projectIdList = array(); + if($menuLibIdList) + { + $libs = $this->dao->select('id,name,product,project')->from(TABLE_DOCLIB)->where('id')->in($menuLibIdList)->fetchAll('id'); + foreach($libs as $lib) + { + if($lib->product) $productIdList[] = $lib->product; + if($lib->project) $projectIdList[] = $lib->project; + } + } + $products = $productIdList ? $this->dao->select('id,name')->from(TABLE_PRODUCT)->where('id')->in($productIdList)->fetchPairs('id', 'name') : array(); + $projects = $projectIdList ? $this->dao->select('id,name')->from(TABLE_PROJECT)->where('id')->in($projectIdList)->fetchPairs('id', 'name') : array(); + foreach($menuLibIdList as $i => $menuLibID) + { + $lib = $libs[$menuLibID]; + $libName = ''; + if($lib->product) $libName = isset($products[$lib->product]) ? '[' . $products[$lib->product] . ']' : ''; + if($lib->project) $libName = isset($projects[$lib->project]) ? '[' . $projects[$lib->project] . ']' : ''; + $libName .= $lib->name; + $customMenu[$i]['link'] = "{$libName}|doc|browse|libID={$menuLibID}"; + } + + foreach($customMenu as $menu) + { + if(isset($menu['link'])) + { + list($menuLabel, $module, $method, $vars) = explode('|', $menu['link']); + $actions .= html::a(helper::createLink($module, $method, $vars), $menuLabel, '', "class='btn btn-gray'"); + } + + } + + } + + $actions .= html::a(helper::createLink('doc', 'createLib'), " " . $this->lang->doc->createLib, '', "class='btn btn-secondary' data-toggle='modal'"); + if($libID) $actions .= html::a(helper::createLink('doc', 'create', "libID=$libID"), " " . $this->lang->doc->create, '', "class='btn btn-primary' data-toggle='modal'"); + + $this->lang->modulePageActions = $actions; + } - $this->app->loadLang('project'); - $selectHtml = "{$this->lang->doclib->all} "; - $selectHtml .= "
"; - $selectHtml .= ""; - $selectHtml .= "
"; - $selectHtml .= "
"; - $selectHtml .= "
"; - if($this->config->global->flow != 'onlyTask' and isset($this->lang->doc->libTypeList['product'])) $selectHtml .= "
{$this->lang->doc->libTypeList['product']}
"; - if($this->config->global->flow != 'onlyStory' and $this->config->global->flow != 'onlyTest' and isset($this->lang->doc->libTypeList['project'])) $selectHtml .= "
{$this->lang->doc->libTypeList['project']}
{$this->lang->project->statusList['done']}
"; - $selectHtml .= "
{$this->lang->doc->libTypeList['custom']}
"; - $selectHtml .= "
"; - common::setMenuVars($this->lang->doc->menu, 'list', $selectHtml); - common::setMenuVars($this->lang->doc->menu, 'crumb', $crumb ? $crumb : $this->getCrumbs($libID, $moduleID)); + //$selectHtml .= $crumb ? $crumb : $this->getCrumbs($libID, $moduleID); + $this->lang->modulePageNav = $selectHtml; } /** @@ -209,7 +311,7 @@ class docModel extends model $docs = $this->dao->select('*')->from(TABLE_DOC) ->where('deleted')->eq(0) ->andWhere('id')->in($docIdList) - ->orderBy($sort) + ->orderBy('editedDate_desc') ->page($pager) ->fetchAll('id'); @@ -246,6 +348,16 @@ class docModel extends model } } } + elseif($browseType == 'visiteddate') + { + $docIdList = $this->getPrivDocs($libID, $moduleID); + $docs = $this->dao->select('*')->from(TABLE_DOC) + ->where('deleted')->eq(0) + ->andWhere('id')->in($docIdList) + ->orderBy('visitedDate_desc') + ->page($pager) + ->fetchAll('id'); + } elseif($browseType == "collectedbyme") { $docs = $this->dao->select('*')->from(TABLE_DOC) @@ -596,7 +708,7 @@ class docModel extends model $this->config->doc->search['queryID'] = $queryID; $this->config->doc->search['params']['product']['values'] = array(''=>'') + $this->loadModel('product')->getPairs('nocode') + array('all'=>$this->lang->doc->allProduct); $this->config->doc->search['params']['project']['values'] = array(''=>'') + $this->loadModel('project')->getPairs('nocode') + array('all'=>$this->lang->doc->allProject); - $this->config->doc->search['params']['lib']['values'] = array(''=>'', $libID => $libs[$libID], 'all' => $this->lang->doclib->all); + $this->config->doc->search['params']['lib']['values'] = array(''=>'', $libID => ($libID ? $libs[$libID] : 0), 'all' => $this->lang->doclib->all); /* Get the modules. */ $moduleOptionMenu = $this->loadModel('tree')->getOptionMenu($libID, 'doc', $startModuleID = 0); @@ -853,7 +965,7 @@ class docModel extends model } } - return array('product' => array_values($productOrderLibs), 'project' => array_values($projectOrderLibs), 'custom' => $customLibs); + return array('product' => $productOrderLibs, 'project' => $projectOrderLibs, 'custom' => $customLibs); } /** diff --git a/module/doc/view/index.html.php b/module/doc/view/index.html.php index b4424a03e0..10d25a843e 100644 --- a/module/doc/view/index.html.php +++ b/module/doc/view/index.html.php @@ -30,17 +30,7 @@ doc->fast;?>