From fb2c2c62f986f718a8b7a38918573569353a3025 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Thu, 20 Mar 2025 09:51:45 +0800 Subject: [PATCH] * [bug#60364] Set parent when upload doc. --- module/doc/control.php | 7 +++++++ module/doc/ui/setdocbasic.html.php | 2 +- module/doc/ui/uploaddocs.html.php | 6 +++--- module/doc/zen.php | 12 +++++++++--- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/module/doc/control.php b/module/doc/control.php index 2de7c41c24..6bd0003bc4 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -497,6 +497,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; if(!$libID) return $this->send(array('result' => 'fail', 'message' => array('lib' => sprintf($this->lang->error->notempty, $this->lang->doc->lib)))); diff --git a/module/doc/ui/setdocbasic.html.php b/module/doc/ui/setdocbasic.html.php index e01a294aca..d6aa2e61a1 100644 --- a/module/doc/ui/setdocbasic.html.php +++ b/module/doc/ui/setdocbasic.html.php @@ -90,7 +90,7 @@ formPanel ( set::name('parent'), set::items($modalType != 'chapter' ? array(0 => '/') + $chapterAndDocs : $chapterAndDocs), - !$isCreate ? set::value(!empty($doc->parent) ? $doc->parent : "m_{$doc->module}") : null, + set::value(!empty($doc->parent) ? $doc->parent : ($moduleID ? "m_$moduleID" : "m_{$doc->module}")), set::required(true) ), ) : null, diff --git a/module/doc/ui/uploaddocs.html.php b/module/doc/ui/uploaddocs.html.php index 823565a72f..fa90bbc487 100644 --- a/module/doc/ui/uploaddocs.html.php +++ b/module/doc/ui/uploaddocs.html.php @@ -78,9 +78,9 @@ formPanel ( setClass('moduleBox'), set::label($lang->doc->module), - set::name('module'), - set::items($optionMenu), - set::value($moduleID), + set::name('parent'), + set::items(array(0 => '/') + $optionMenu), + set::value($moduleID ? "m_$moduleID" : 0), set::required(true) ), formGroup diff --git a/module/doc/zen.php b/module/doc/zen.php index 6f95e0c8b8..5c58084e40 100644 --- a/module/doc/zen.php +++ b/module/doc/zen.php @@ -584,9 +584,15 @@ class docZen extends doc { $this->assignVarsForCreate($objectType, $objectID, $libID, $moduleID, $docType); - $this->view->title = empty($lib) ? '' : zget($lib, 'name', '', $lib->name . $this->lang->hyphen) . $this->lang->doc->uploadDoc; - $this->view->linkType = $objectType; - $this->view->spaces = ($objectType == 'mine' || $objectType == 'custom') ? $this->doc->getSubSpacesByType($objectType, false) : array(); + $chapterAndDocs = $this->doc->getDocsOfLibs(array($libID), $objectType); + $modulePairs = empty($libID) ? 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->title = empty($lib) ? '' : zget($lib, 'name', '', $lib->name . $this->lang->hyphen) . $this->lang->doc->uploadDoc; + $this->view->linkType = $objectType; + $this->view->spaces = ($objectType == 'mine' || $objectType == 'custom') ? $this->doc->getSubSpacesByType($objectType, false) : array(); + $this->view->optionMenu = $chapterAndDocs; } /**