diff --git a/module/doc/control.php b/module/doc/control.php index be5cd77631..483ad8c339 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -42,29 +42,30 @@ class doc extends control } /** + * 我的空间。 * My space. * - * @param string $type mine|view|collect|createdBy - * @param int $libID - * @param int $moduleID - * @param string $browseType all|draft|bysearch - * @param int $param - * @param string $orderBy - * @param int $recTotal - * @param int $recPerPage - * @param int $pageID + * @param string $type mine|view|collect|createdBy + * @param int $libID + * @param int $moduleID + * @param string $browseType all|draft|bysearch + * @param int $param + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ - public function mySpace($type = 'mine', $libID = 0, $moduleID = 0, $browseType = 'all', $param = 0, $orderBy = '', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function mySpace(string $type = 'mine', int $libID = 0, int $moduleID = 0, string $browseType = 'all', int $param = 0, string $orderBy = '', int $recTotal = 0, int $recPerPage = 20, int $pageID = 1) { $browseType = strtolower($browseType); $type = strtolower($type); - if(empty($orderBy) and $type == 'mine') $orderBy = 'status,editedDate_desc'; - if(empty($orderBy) and ($type == 'view' or $type == 'collect')) $orderBy = 'status,date_desc'; - if(empty($orderBy) and ($type == 'createdby')) $orderBy = 'status,addedDate_desc'; - if(empty($orderBy) and ($type == 'editedby')) $orderBy = 'status,editedDate_desc'; + if(empty($orderBy) && $type == 'mine') $orderBy = 'status,editedDate_desc'; + if(empty($orderBy) && ($type == 'view' || $type == 'collect')) $orderBy = 'status,date_desc'; + if(empty($orderBy) && ($type == 'createdby')) $orderBy = 'status,addedDate_desc'; + if(empty($orderBy) && ($type == 'editedby')) $orderBy = 'status,editedDate_desc'; /* Save session, load module. */ $uri = $this->app->getURI(true); @@ -83,12 +84,11 @@ class doc extends control $objectDropdown = "
{$objectTitle}
"; /* Build the search form. */ - $queryID = $browseType == 'bysearch' ? (int)$param : 0; - $params = "libID=$libID&moduleID=$moduleID&browseType=bySearch¶m=myQueryID&orderBy=$orderBy"; - if($this->app->rawMethod == 'myspace') $params = "type=$type&$params"; + $queryID = $browseType == 'bysearch' ? $param : 0; + $params = "libID={$libID}&moduleID={$moduleID}&browseType=bySearch¶m=myQueryID&orderBy={$orderBy}"; + if($this->app->rawMethod == 'myspace') $params = "type={$type}&{$params}"; $actionURL = $this->createLink('doc', $this->app->rawMethod, $params); - - $this->doc->buildSearchForm($libID, $libs, $queryID, $actionURL, $type); + $this->docZen->buildSearchForm($libID, $libs, $queryID, $actionURL, $type); /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -96,10 +96,12 @@ class doc extends control /* Append id for second sort. */ $sort = common::appendOrder($orderBy); + + /* Get doc list data. */ $docs = array(); if($type == 'mine') { - if($browseType != 'bysearch' and !$libID) + if($browseType != 'bysearch' && !$libID) { $docs = array(); } @@ -108,31 +110,12 @@ class doc extends control $docs = $browseType == 'bysearch' ? $this->doc->getDocsBySearch('mine', 0, $libID, $queryID, $orderBy, $pager) : $this->doc->getDocs($libID, $moduleID, $browseType, $orderBy, $pager); } } - elseif($type == 'view' or $type == 'collect' or $type == 'createdby' or $type == 'editedby') + elseif(in_array($type, array('view', 'collect', 'createdby', 'editedby'))) { $docs = $this->doc->getMineList($type, $browseType, $orderBy, $pager, $queryID); } - $this->view->title = $this->lang->doc->common; - $this->view->moduleID = $moduleID; - $this->view->docs = $docs; - $this->view->users = $this->user->getPairs('noletter'); - $this->view->orderBy = $orderBy; - $this->view->browseType = $browseType; - $this->view->param = $param; - $this->view->libID = $libID; - $this->view->lib = $this->doc->getLibById($libID); - $this->view->libTree = $this->doc->getLibTree($type != 'mine' ? 0 : $libID, $libs, 'mine', $moduleID, 0, $browseType); - $this->view->pager = $pager; - $this->view->type = $type; - $this->view->objectID = 0; - $this->view->canExport = ($this->config->edition != 'open' and common::hasPriv('doc', 'mine2export') and $type == 'mine'); - $this->view->libType = 'lib'; - $this->view->objectDropdown = $objectDropdown; - $this->view->spaceType = 'mine'; - $this->view->linkParams = "objectID=$objectID&%s&browseType=&orderBy=$orderBy¶m=0"; - $this->view->defaultNestedShow = $this->docZen->getDefacultNestedShow($libID, $moduleID, $type); - + $this->docZen->assignVarsForMySpace($type, $objectID, $libID, $moduleID, $browseType, $param, $orderBy, $docs, $pager, $libs, $objectDropdown); $this->display(); } @@ -1225,7 +1208,7 @@ class doc extends control } else { - $this->doc->buildSearchForm($libID, $libs, $queryID, $actionURL, $type); + $this->docZen->buildSearchForm($libID, $libs, $queryID, $actionURL, $type); } /* Load pager. */ diff --git a/module/doc/model.php b/module/doc/model.php index 3dcc18f779..8731d54adb 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1082,73 +1082,6 @@ class docModel extends model $this->dao->update(TABLE_DOC)->data($doc)->where('id')->eq($docID)->exec(); } - /** - * Build search form. - * - * @param string $libID - * @param array $libs - * @param int $queryID - * @param string $actionURL - * @access public - * @return void - */ - public function buildSearchForm($libID, $libs, $queryID, $actionURL, $type) - { - $this->loadModel('product'); - - if($this->app->rawMethod == 'contribute') - { - $this->config->doc->search['module'] = 'contributeDoc'; - $products = $this->product->getPairs(); - - $this->config->doc->search['params']['project']['values'] = $this->loadModel('project')->getPairsByProgram(0, 'all', false, 'order_asc', $this->config->vision == 'rnd' ? 'kanban' : '') + array('all' => $this->lang->doc->allProjects); - $this->config->doc->search['params']['execution']['values'] = $this->loadModel('execution')->getPairs(0, 'sprint,stage', 'multiple,leaf,noprefix,withobject') + array('all' => $this->lang->doc->allExecutions); - $this->config->doc->search['params']['lib']['values'] = $this->loadModel('doc')->getLibs('all', 'withObject') + array('all' => $this->lang->doclib->all); - $this->config->doc->search['params']['product']['values'] = $products + array('all' => $this->lang->doc->allProduct); - - unset($this->config->doc->search['fields']['module']); - } - else - { - if(!isset($libs[$libID])) $libs[$libID] = $this->getLibById($libID); - - $libPairs = array(); - $queryName = $type . 'libDoc'; - foreach($libs as $lib) - { - if(empty($lib)) continue; - if($lib->type == 'api') continue; - $libPairs[$lib->id] = $lib->name; - } - - if($type == 'project') - { - $this->config->doc->search['params']['execution']['values'] = $this->loadModel('execution')->getPairs($this->session->project, 'sprint,stage', 'multiple,leaf,noprefix') + array('all' => $this->lang->doc->allExecutions); - } - else - { - if($type == 'mine' or $type == 'createdby') - { - unset($this->config->doc->search['fields']['addedBy']); - if($type == 'mine') unset($this->config->doc->search['fields']['editedBy']); - } - unset($this->config->doc->search['fields']['execution']); - } - - if(in_array($type, array('view', 'collect', 'createdby', 'editedby'))) $libPairs = $this->getLibs('all', 'withObject'); - - $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']['module']); - } - - $this->config->doc->search['actionURL'] = $actionURL; - $this->config->doc->search['queryID'] = $queryID; - - $this->loadModel('search')->setSearchParams($this->config->doc->search); - } - /** * Build search query. * diff --git a/module/doc/zen.php b/module/doc/zen.php index 88e9e6fa6c..0e0d277cf4 100644 --- a/module/doc/zen.php +++ b/module/doc/zen.php @@ -182,4 +182,112 @@ class docZen extends doc $path = implode(':', $path); return array("{$prefix}{$libID}:{$path}" => true); } + + /** + * 构造搜索表单。 + * Build search form. + * + * @param string $libID + * @param array $libs + * @param int $queryID + * @param string $actionURL + * @param string $type mine|view|collect|createdBy|product|project|execution|custom + * @access protected + * @return void + */ + protected function buildSearchForm(int $libID, array $libs, int $queryID, string $actionURL, string $type): void + { + $this->loadModel('product'); + if($this->app->rawMethod == 'contribute') + { + $this->config->doc->search['module'] = 'contributeDoc'; + $this->config->doc->search['params']['project']['values'] = $this->loadModel('project')->getPairsByProgram(0, 'all', false, 'order_asc', $this->config->vision == 'rnd' ? 'kanban' : '') + array('all' => $this->lang->doc->allProjects); + $this->config->doc->search['params']['execution']['values'] = $this->loadModel('execution')->getPairs(0, 'sprint,stage', 'multiple,leaf,noprefix,withobject') + array('all' => $this->lang->doc->allExecutions); + $this->config->doc->search['params']['lib']['values'] = $this->loadModel('doc')->getLibs('all', 'withObject') + array('all' => $this->lang->doclib->all); + $this->config->doc->search['params']['product']['values'] = $this->product->getPairs() + array('all' => $this->lang->doc->allProduct); + + unset($this->config->doc->search['fields']['module'], $this->config->doc->search['params']['module']); + } + else + { + if(!isset($libs[$libID])) $libs[$libID] = $this->doc->getLibByID($libID); + + $libPairs = array(); + $queryName = $type . 'libDoc'; + foreach($libs as $lib) + { + if(empty($lib)) continue; + if($lib->type == 'api') continue; + $libPairs[$lib->id] = $lib->name; + } + + if($type == 'project') + { + $this->config->doc->search['params']['execution']['values'] = $this->loadModel('execution')->getPairs($this->session->project, 'sprint,stage', 'multiple,leaf,noprefix') + array('all' => $this->lang->doc->allExecutions); + } + else + { + if($type == 'mine' || $type == 'createdby') + { + unset($this->config->doc->search['fields']['addedBy'], $this->config->doc->search['params']['addedBy']); + if($type == 'mine') unset($this->config->doc->search['fields']['editedBy'], $this->config->doc->search['params']['editedBy']); + } + unset($this->config->doc->search['fields']['execution'], $this->config->doc->search['params']['execution']); + } + + if(in_array($type, array('view', 'collect', 'createdby', 'editedby'))) $libPairs = $this->doc->getLibs('all', 'withObject'); + + $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'], $this->config->doc->search['params']['product']); + unset($this->config->doc->search['fields']['module'], $this->config->doc->search['params']['module']); + } + + unset($this->config->doc->search['params']['status']['values']['']); + $this->config->doc->search['actionURL'] = $actionURL; + $this->config->doc->search['queryID'] = $queryID; + + $this->loadModel('search')->setSearchParams($this->config->doc->search); + } + + /** + * 展示我的空间相关变量。 + * Show my space related variables. + * + * @param string $type + * @param int $objectID + * @param int $libID + * @param int $moduleID + * @param string $browseType + * @param int $param + * @param string $orderBy + * @param array $docs + * @param object $pager + * @param array $libs + * @param string $objectDropdown + * @access protected + * @return void + */ + protected function assignVarsForMySpace(string $type, int $objectID, int $libID, int $moduleID, string $browseType, int $param, string $orderBy, array $docs, object $pager, array $libs, string $objectDropdown): void + { + $this->view->title = $this->lang->doc->common; + $this->view->type = $type; + $this->view->libID = $libID; + $this->view->moduleID = $moduleID; + $this->view->browseType = $browseType; + $this->view->param = $param; + $this->view->orderBy = $orderBy; + $this->view->docs = $docs; + $this->view->pager = $pager; + $this->view->objectDropdown = $objectDropdown; + $this->view->objectID = 0; + $this->view->libType = 'lib'; + $this->view->spaceType = 'mine'; + $this->view->users = $this->user->getPairs('noletter'); + $this->view->lib = $this->doc->getLibById($libID); + $this->view->libTree = $this->doc->getLibTree($type != 'mine' ? 0 : $libID, $libs, 'mine', $moduleID, 0, $browseType); + $this->view->canExport = ($this->config->edition != 'open' && common::hasPriv('doc', 'mine2export') && $type == 'mine'); + $this->view->linkParams = "objectID={$objectID}&%s&browseType=&orderBy={$orderBy}¶m=0"; + $this->view->defaultNestedShow = $this->getDefacultNestedShow($libID, $moduleID, $type); + } }