From 277f6a75bbe080ea167b62968aaf3921a823da53 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Thu, 20 Mar 2025 08:40:48 +0800 Subject: [PATCH] * [bug#60364] Set parent and moudle when select module. --- module/doc/control.php | 27 +++++++++++++++++++-------- module/doc/ui/setdocbasic.html.php | 13 +++---------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/module/doc/control.php b/module/doc/control.php index 7f371b7cbc..4ace6696f5 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -562,6 +562,13 @@ class doc extends control { if(!empty($_POST)) { + /* parent带‘m_’前缀为目录。*/ + if(isset($_POST['parent']) && strpos($_POST['parent'], 'm_') !== false) + { + $_POST['module'] = str_replace('m_', '', $_POST['parent']); + $_POST['parent'] = 0; + } + $libID = (int)$this->post->lib; $docLib = $this->loadModel('doc')->getLibByID($libID); if($docLib) @@ -634,6 +641,13 @@ class doc extends control $doc = $this->doc->getByID($docID); if(!empty($_POST)) { + /* parent带‘m_’前缀为目录。*/ + if(isset($_POST['parent']) && strpos($_POST['parent'], 'm_') !== false) + { + $_POST['module'] = str_replace('m_', '', $_POST['parent']); + $_POST['parent'] = 0; + } + if(!$doc) return $this->send(array('result' => 'fail', 'message' => $this->lang->doc->errorNotFound)); $isOpen = $doc->acl == 'open'; @@ -1953,14 +1967,11 @@ class doc extends control } if($modalType == 'chapter') $title = $isCreate ? $this->lang->doc->addChapter : $this->lang->doc->editChapter; - if($parentID || (isset($doc) && $doc->parent)) - { - $chapterAndDocs = $this->doc->getDocsOfLibs(array($libID), $objectType, $docID); - $modulePairs = empty($libID) || $modalType == 'chapter' ? array() : $this->loadModel('tree')->getOptionMenu($libID, 'doc', 0); - if(isset($doc) && !isset($chapterAndDocs[$doc->parent])) $chapterAndDocs[$doc->parent] = $this->doc->fetchByID($doc->parent); - $chapterAndDocs = $this->doc->buildNestedDocs($chapterAndDocs, $modulePairs); - $this->view->chapterAndDocs = $chapterAndDocs; - } + $chapterAndDocs = $this->doc->getDocsOfLibs(array($libID), $objectType, $docID); + $modulePairs = empty($libID) || $modalType == 'chapter' ? array() : $this->loadModel('tree')->getOptionMenu($libID, 'doc', 0); + if(isset($doc) && !empty($doc->parent) && !isset($chapterAndDocs[$doc->parent])) $chapterAndDocs[$doc->parent] = $this->doc->fetchByID($doc->parent); + $chapterAndDocs = $this->doc->buildNestedDocs($chapterAndDocs, $modulePairs); + $this->view->chapterAndDocs = $chapterAndDocs; if($isCreate) { diff --git a/module/doc/ui/setdocbasic.html.php b/module/doc/ui/setdocbasic.html.php index 2500da8a24..6739a199f7 100644 --- a/module/doc/ui/setdocbasic.html.php +++ b/module/doc/ui/setdocbasic.html.php @@ -86,20 +86,13 @@ formPanel ( set::width('1/2'), set::label($lang->doc->module), - $modalType == 'doc' && !$parentID && empty($doc->parent) ? picker - ( - set::name('module'), - set::items($optionMenu), - set::value($moduleID), - set::required(true) - ) : null, - ($modalType == 'doc' && $parentID) || !empty($doc->parent) ? picker + picker ( set::name('parent'), - set::items($chapterAndDocs), + set::items($modalType != 'chapter' ? array(0 => '/') + $chapterAndDocs : $chapterAndDocs), set::value(!empty($doc->parent) ? $doc->parent : $parentID), set::required(true) - ) : null, + ), ) : null, $objectType !== 'mine' && $modalType != 'chapter' ? formGroup (