From 403bfaa3aa9e61fc8fc116348ac468939a42a007 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 28 Nov 2023 14:37:41 +0800 Subject: [PATCH] * Refactor doc::buildSearchForm method. --- module/doc/control.php | 4 +-- module/doc/model.php | 67 ++++++++++++++++++++++++++++++++++++++++++ module/doc/zen.php | 67 ------------------------------------------ 3 files changed, 69 insertions(+), 69 deletions(-) diff --git a/module/doc/control.php b/module/doc/control.php index 483ad8c339..ee231c5298 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -88,7 +88,7 @@ class doc extends control $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->docZen->buildSearchForm($libID, $libs, $queryID, $actionURL, $type); + $this->doc->buildSearchForm($libID, $libs, $queryID, $actionURL, $type); /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -1208,7 +1208,7 @@ class doc extends control } else { - $this->docZen->buildSearchForm($libID, $libs, $queryID, $actionURL, $type); + $this->doc->buildSearchForm($libID, $libs, $queryID, $actionURL, $type); } /* Load pager. */ diff --git a/module/doc/model.php b/module/doc/model.php index 6f481bd378..4f14cba734 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -3448,4 +3448,71 @@ class docModel extends model return $editors; } + + /** + * 构造搜索表单。 + * Build search form. + * + * @param string $libID + * @param array $libs + * @param int $queryID + * @param string $actionURL + * @param string $type mine|product|project|execution|custom + * @access public + * @return void + */ + public 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->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->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); + } } diff --git a/module/doc/zen.php b/module/doc/zen.php index 0e0d277cf4..359010370f 100644 --- a/module/doc/zen.php +++ b/module/doc/zen.php @@ -183,73 +183,6 @@ class docZen extends doc 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.