diff --git a/module/api/control.php b/module/api/control.php index d6caa69e34..136a764518 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -84,21 +84,20 @@ class api extends control $this->api->buildSearchForm($lib, $queryID, $actionURL, $libs); } - $this->view->title = $this->lang->api->pageTitle; - $this->view->lib = $lib; - $this->view->libID = $libID; - $this->view->libs = $libs; - $this->view->release = $release; - $this->view->objectType = $objectType; - $this->view->objectID = $objectID; - $this->view->moduleID = $moduleID; - $this->view->version = $version; - $this->view->apiList = $browseType == 'bySearch' ? $this->api->getApiListBySearch($libID, $queryID, '', array_keys($libs)) : $this->api->getListByModuleID($libID, $moduleID, $release); - $this->view->libTree = $this->doc->getLibTree($libID, $libs, 'api', $moduleID, $objectID, $browseType, (int)$param); - $this->view->objectDropdown = isset($libs[$libID]) ? $this->apiZen->generateLibsDropMenu($libs[$libID], $release) : ''; - $this->view->spaceType = 'api'; - $this->view->linkParams = '%s'; - $this->view->defaultNestedShow = $this->apiZen->getDefaultNestedShow($libID, $moduleID); + $this->view->title = $this->lang->api->pageTitle; + $this->view->lib = $lib; + $this->view->libID = $libID; + $this->view->libs = $libs; + $this->view->release = $release; + $this->view->objectType = $objectType; + $this->view->objectID = $objectID; + $this->view->moduleID = $moduleID; + $this->view->version = $version; + $this->view->apiList = $browseType == 'bySearch' ? $this->api->getApiListBySearch($libID, $queryID, '', array_keys($libs)) : $this->api->getListByModuleID($libID, $moduleID, $release); + $this->view->libTree = $this->doc->getLibTree($libID, $libs, 'api', $moduleID, $objectID, $browseType, (int)$param); + $this->view->objectDropdown = isset($libs[$libID]) ? $this->apiZen->generateLibsDropMenu($libs[$libID], $release) : ''; + $this->view->spaceType = 'api'; + $this->view->linkParams = '%s'; $this->display(); } diff --git a/module/api/zen.php b/module/api/zen.php index 2f6ea0d01c..73b081b77f 100644 --- a/module/api/zen.php +++ b/module/api/zen.php @@ -11,26 +11,6 @@ declare(strict_types=1); */ class apiZen extends api { - /** - * 设置文档树默认展开的节点。 - * Set the default expanded nodes of the document tree. - * - * @param int $libID - * @param int $moduleID - * @access protected - * @return array - */ - protected function getDefaultNestedShow(int $libID, int $moduleID): array - { - if(!$libID && !$moduleID) return array(); - if($libID && !$moduleID) return array("{$libID}" => true); - - $module = $this->loadModel('tree')->getByID($moduleID); - $path = explode(',', trim($module->path, ',')); - $path = implode(':', $path); - return array("{$libID}:{$path}" => true); - } - /** * 解析cookie里的docSpaceParam值。 * Parse docSpaceParam cookie. @@ -67,15 +47,14 @@ class apiZen extends api $libTree = $this->doc->getLibTree($libID, $libs, $spaceType, $moduleID); } - $this->view->type = $type; - $this->view->objectType = $type; - $this->view->objectID = $objectID; - $this->view->libID = $libID; - $this->view->moduleID = $moduleID; - $this->view->libTree = $libTree; - $this->view->objectDropdown = $objectDropdown; - $this->view->spaceType = $spaceType; - $this->view->defaultNestedShow = $this->getDefaultNestedShow($libID, $moduleID); + $this->view->type = $type; + $this->view->objectType = $type; + $this->view->objectID = $objectID; + $this->view->libID = $libID; + $this->view->moduleID = $moduleID; + $this->view->libTree = $libTree; + $this->view->objectDropdown = $objectDropdown; + $this->view->spaceType = $spaceType; } /** diff --git a/module/doc/control.php b/module/doc/control.php index 79cfadadae..0be3b55d80 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -390,7 +390,6 @@ class doc extends control $this->view->spaces = $this->docZen->getAllSpaces(); $this->view->libTree = $this->doc->getLibTree((int)$libID, $libs, $objectType, (int)$moduleID, (int)$objectID); $this->view->linkParams = "objectID={$objectID}&%s&browseType=&orderBy=status,id_desc¶m=0"; - $this->view->defaultNestedShow = $this->getDefaultNestedShow((int)$libID, (int)$moduleID, $objectType); if(!empty($objectType) && $objectType !== 'custom') { @@ -450,26 +449,25 @@ class doc extends control if($lib->type == 'custom' || $lib->type == 'mine') $this->view->spaces = $this->docZen->getAllSpaces($lib->type == 'mine' ? 'onlymine' : 'nomine'); $this->docZen->setObjectsForEdit($lib->type, $objectID); - $this->view->title = $lib->name . $this->lang->hyphen . $this->lang->doc->edit; - $this->view->doc = $doc; - $this->view->optionMenu = $this->loadModel('tree')->getOptionMenu($libID, 'doc', $startModuleID = 0); - $this->view->type = $lib->type; - $this->view->libs = $libPairs; - $this->view->lib = $lib; - $this->view->libID = $libID; - $this->view->libTree = $this->doc->getLibTree($libID, $libs, $objectType, $moduleID, (int)$objectID, '', 0, $docID); - $this->view->groups = $this->loadModel('group')->getPairs(); - $this->view->users = $this->user->getPairs('noletter|noclosed|nodeleted', $doc->users); - $this->view->files = $this->loadModel('file')->getByObject('doc', $docID); - $this->view->objectType = $objectType; - $this->view->object = $object; - $this->view->objectID = $objectID; - $this->view->objectDropdown = $objectDropdown; - $this->view->moduleID = $moduleID; - $this->view->spaceType = $objectType; - $this->view->defaultNestedShow = $this->getDefaultNestedShow($libID, $moduleID); - $this->view->linkParams = "objectID={$objectID}&%s&browseType=&orderBy=status,id_desc¶m=0"; - $this->view->otherEditing = $this->doc->checkOtherEditing($docID); + $this->view->title = $lib->name . $this->lang->hyphen . $this->lang->doc->edit; + $this->view->doc = $doc; + $this->view->optionMenu = $this->loadModel('tree')->getOptionMenu($libID, 'doc', $startModuleID = 0); + $this->view->type = $lib->type; + $this->view->libs = $libPairs; + $this->view->lib = $lib; + $this->view->libID = $libID; + $this->view->libTree = $this->doc->getLibTree($libID, $libs, $objectType, $moduleID, (int)$objectID, '', 0, $docID); + $this->view->groups = $this->loadModel('group')->getPairs(); + $this->view->users = $this->user->getPairs('noletter|noclosed|nodeleted', $doc->users); + $this->view->files = $this->loadModel('file')->getByObject('doc', $docID); + $this->view->objectType = $objectType; + $this->view->object = $object; + $this->view->objectID = $objectID; + $this->view->objectDropdown = $objectDropdown; + $this->view->moduleID = $moduleID; + $this->view->spaceType = $objectType; + $this->view->linkParams = "objectID={$objectID}&%s&browseType=&orderBy=status,id_desc¶m=0"; + $this->view->otherEditing = $this->doc->checkOtherEditing($docID); $this->display(); } @@ -685,30 +683,29 @@ class doc extends control $this->docZen->buildSearchFormForShowFiles($type, $objectID, $viewType, $param); - $this->view->title = $object->name; - $this->view->type = $type; - $this->view->object = $object; - $this->view->files = $this->docZen->processFiles($files, $fileIcon, $sourcePairs); - $this->view->fileIcon = $fileIcon; - $this->view->sourcePairs = $sourcePairs; - $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->view->pager = $pager; - $this->view->viewType = $viewType; - $this->view->orderBy = $orderBy; - $this->view->objectID = $objectID; - $this->view->canBeChanged = common::canModify($type, $object); // Determines whether an object is editable. - $this->view->summary = $this->doc->summary($files); - $this->view->libTree = $this->doc->getLibTree(0, $libs, $type, 0, $objectID); - $this->view->objectDropdown = $objectDropdown; - $this->view->searchTitle = $searchTitle; - $this->view->linkParams = "objectID=$objectID&%s&browseType=&orderBy=status,id_desc¶m=0"; - $this->view->spaceType = $type; - $this->view->objectType = $type; - $this->view->browseType = $browseType; - $this->view->param = $param; - $this->view->libID = 0; - $this->view->moduleID = 0; - $this->view->defaultNestedShow = $this->docZen->getDefaultNestedShow(0, 0, $type); + $this->view->title = $object->name; + $this->view->type = $type; + $this->view->object = $object; + $this->view->files = $this->docZen->processFiles($files, $fileIcon, $sourcePairs); + $this->view->fileIcon = $fileIcon; + $this->view->sourcePairs = $sourcePairs; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->view->pager = $pager; + $this->view->viewType = $viewType; + $this->view->orderBy = $orderBy; + $this->view->objectID = $objectID; + $this->view->canBeChanged = common::canModify($type, $object); // Determines whether an object is editable. + $this->view->summary = $this->doc->summary($files); + $this->view->libTree = $this->doc->getLibTree(0, $libs, $type, 0, $objectID); + $this->view->objectDropdown = $objectDropdown; + $this->view->searchTitle = $searchTitle; + $this->view->linkParams = "objectID=$objectID&%s&browseType=&orderBy=status,id_desc¶m=0"; + $this->view->spaceType = $type; + $this->view->objectType = $type; + $this->view->browseType = $browseType; + $this->view->param = $param; + $this->view->libID = 0; + $this->view->moduleID = 0; $this->display(); } @@ -811,29 +808,26 @@ class doc extends control $this->view->$objectKey = $objectID; } - $executionID = $type == 'project' && $lib->type == 'execution' ? $lib->execution : 0; - - $this->view->title = $type == 'custom' ? $this->lang->doc->tableContents : $object->name . $this->lang->hyphen . $this->lang->doc->tableContents; - $this->view->type = $type; - $this->view->objectType = $type; - $this->view->spaceType = $type; - $this->view->browseType = $browseType; - $this->view->isFirstLoad = $isFirstLoad; - $this->view->param = $queryID; - $this->view->users = $this->user->getPairs('noletter'); - $this->view->libTree = $this->doc->getLibTree($libID, $libs, $type, $moduleID, $objectID, $browseType, (int)$param); - $this->view->libID = $libID; - $this->view->moduleID = $moduleID; - $this->view->objectDropdown = $objectDropdown; - $this->view->lib = $lib; - $this->view->libType = $libType; - $this->view->objectID = $objectID; - $this->view->orderBy = $orderBy; - $this->view->release = $browseType == 'byrelease' ? $param : 0; - $this->view->exportMethod = $libType == 'api' ? 'export' : $type . '2export'; - $this->view->linkParams = "objectID={$objectID}&%s&browseType=&orderBy={$orderBy}¶m=0"; - $this->view->defaultNestedShow = $this->docZen->getDefaultNestedShow($libID, $moduleID, $type, $executionID); - $this->view->canUpdateOrder = $lib && !($lib->type == 'custom' && $lib->parent == 0) && common::hasPriv('doc', 'sortDoc') && $orderBy == 'order_asc'; + $this->view->title = $type == 'custom' ? $this->lang->doc->tableContents : $object->name . $this->lang->hyphen . $this->lang->doc->tableContents; + $this->view->type = $type; + $this->view->objectType = $type; + $this->view->spaceType = $type; + $this->view->browseType = $browseType; + $this->view->isFirstLoad = $isFirstLoad; + $this->view->param = $queryID; + $this->view->users = $this->user->getPairs('noletter'); + $this->view->libTree = $this->doc->getLibTree($libID, $libs, $type, $moduleID, $objectID, $browseType, (int)$param); + $this->view->libID = $libID; + $this->view->moduleID = $moduleID; + $this->view->objectDropdown = $objectDropdown; + $this->view->lib = $lib; + $this->view->libType = $libType; + $this->view->objectID = $objectID; + $this->view->orderBy = $orderBy; + $this->view->release = $browseType == 'byrelease' ? $param : 0; + $this->view->exportMethod = $libType == 'api' ? 'export' : $type . '2export'; + $this->view->linkParams = "objectID={$objectID}&%s&browseType=&orderBy={$orderBy}¶m=0"; + $this->view->canUpdateOrder = $lib && !($lib->type == 'custom' && $lib->parent == 0) && common::hasPriv('doc', 'sortDoc') && $orderBy == 'order_asc'; $this->display(); } diff --git a/module/doc/ui/lefttree.html.php b/module/doc/ui/lefttree.html.php index 887d976ed6..569c8b69c8 100644 --- a/module/doc/ui/lefttree.html.php +++ b/module/doc/ui/lefttree.html.php @@ -42,7 +42,7 @@ sidebar set::menuLink(isset($objectDropdown['link']) ? $objectDropdown['link'] : ''), set::settingLink($app->rawModule == 'doc' && $app->rawMethod == 'view' && common::hasPriv('doc', 'displaySetting') ? inlink('displaySetting') : ''), set::settingText($lang->doc->displaySetting), - set::defaultNestedShow($defaultNestedShow) + set::defaultNestedShow(true) ) ); diff --git a/module/doc/zen.php b/module/doc/zen.php index 3b55ad23b1..3626208204 100644 --- a/module/doc/zen.php +++ b/module/doc/zen.php @@ -158,30 +158,6 @@ class docZen extends doc return $outlineTree; } - /** - * 设置文档树默认展开的节点。 - * Set the default expanded nodes of the document tree. - * - * @param int $libID - * @param int $moduleID - * @param string $objectType mine|product|project|execution|custom - * @param int $executionID - * @access protected - * @return array - */ - protected function getDefaultNestedShow(int $libID, int $moduleID, string $objectType = '', int $executionID = 0): array - { - if(!$libID && !$moduleID) return array(); - - $prefix = $objectType == 'mine' ? "0:" : ''; - if($libID && !$moduleID) return array("{$prefix}{$libID}" => true); - - $module = $this->loadModel('tree')->getByID($moduleID); - $path = explode(',', trim($module->path, ',')); - $path = implode(':', $path); - return array("{$prefix}{$libID}:{$path}" => true); - } - /** * 展示我的空间相关变量。 * Show my space related variables. @@ -202,26 +178,25 @@ class docZen extends doc */ protected function assignVarsForMySpace(string $type, int $objectID, int $libID, int $moduleID, string $browseType, int $param, string $orderBy, array $docs, object $pager, array $libs, string $objectTitle): 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->objectTitle = $objectTitle; - $this->view->objectID = 0; - $this->view->canUpdateOrder = common::hasPriv('doc', 'sortDoc') && $orderBy == 'order_asc'; - $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->getDefaultNestedShow($libID, $moduleID, $type); + $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->objectTitle = $objectTitle; + $this->view->objectID = 0; + $this->view->canUpdateOrder = common::hasPriv('doc', 'sortDoc') && $orderBy == 'order_asc'; + $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"; } /** @@ -731,40 +706,32 @@ class docZen extends doc */ protected function assignVarsForView(int $docID, int $version, string $type, int $objectID, int $libID, object $doc, object $object, string $objectType, array $libs, array $objectDropdown): void { - $defaultNestedShow = $this->getDefaultNestedShow($libID, (int)$doc->module, $type); - if($defaultNestedShow) - { - $showNested = key($defaultNestedShow) . ":{$docID}"; - $defaultNestedShow = array($showNested => true); - } - - $this->view->title = $this->lang->doc->common . $this->lang->hyphen . $doc->title; - $this->view->docID = $docID; - $this->view->type = $type; - $this->view->objectID = $objectID; - $this->view->libID = $libID; - $this->view->doc = $doc; - $this->view->version = $version; - $this->view->object = $object; - $this->view->objectType = $objectType; - $this->view->lib = isset($libs[$libID]) ? $libs[$libID] : new stdclass(); - $this->view->libs = $libs; - $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->loadModel('user')->getPairs('noclosed,noletter'); - $this->view->libTree = $this->doc->getLibTree((int)$libID, (array)$libs, $type, (int)$doc->module, (int)$objectID, '', 0, $docID); - $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('doc', $docID); - $this->view->moduleID = $doc->module; - $this->view->objectDropdown = $objectDropdown; - $this->view->canExport = ($this->config->edition != 'open' && common::hasPriv('doc', $type . '2export')); - $this->view->exportMethod = $type . '2export'; - $this->view->editors = $this->doc->getEditors($docID); - $this->view->linkParams = "objectID={$objectID}&%s&browseType=&orderBy=status,id_desc¶m=0"; - $this->view->spaceType = $objectType; - $this->view->productID = $doc->product; - $this->view->projectID = $doc->project; - $this->view->executionID = $doc->execution; - $this->view->defaultNestedShow = $defaultNestedShow; + $this->view->title = $this->lang->doc->common . $this->lang->hyphen . $doc->title; + $this->view->docID = $docID; + $this->view->type = $type; + $this->view->objectID = $objectID; + $this->view->libID = $libID; + $this->view->doc = $doc; + $this->view->version = $version; + $this->view->object = $object; + $this->view->objectType = $objectType; + $this->view->lib = isset($libs[$libID]) ? $libs[$libID] : new stdclass(); + $this->view->libs = $libs; + $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->loadModel('user')->getPairs('noclosed,noletter'); + $this->view->libTree = $this->doc->getLibTree((int)$libID, (array)$libs, $type, (int)$doc->module, (int)$objectID, '', 0, $docID); + $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('doc', $docID); + $this->view->moduleID = $doc->module; + $this->view->objectDropdown = $objectDropdown; + $this->view->canExport = ($this->config->edition != 'open' && common::hasPriv('doc', $type . '2export')); + $this->view->exportMethod = $type . '2export'; + $this->view->editors = $this->doc->getEditors($docID); + $this->view->linkParams = "objectID={$objectID}&%s&browseType=&orderBy=status,id_desc¶m=0"; + $this->view->spaceType = $objectType; + $this->view->productID = $doc->product; + $this->view->projectID = $doc->project; + $this->view->executionID = $doc->execution; } /**