From a9287d2d95409956301199defb9f2ac5824fd0f9 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 27 Jul 2023 16:43:06 +0800 Subject: [PATCH] * Change the process file field code. --- module/doc/control.php | 13 ++++---- module/doc/ui/showfiles.html.php | 26 --------------- module/doc/zen.php | 54 ++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 module/doc/zen.php diff --git a/module/doc/control.php b/module/doc/control.php index 8b8a299231..dbd9973b3e 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -1009,13 +1009,16 @@ class doc extends control $pager = new pager($recTotal, $recPerPage, $pageID); $this->app->rawMethod = $rawMethod; - $files = $this->doc->getLibFiles($type, $objectID, $orderBy, $pager); - - $this->view->title = $object->name; + $files = $this->doc->getLibFiles($type, $objectID, $orderBy, $pager); + $fileIcon = $this->doc->getFileIcon($files); + $sourcePairs = $this->doc->getFileSourcePairs($files); + $this->view->title = $object->name; $this->view->type = $type; $this->view->object = $object; - $this->view->files = $files; + $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; @@ -1023,8 +1026,6 @@ class doc extends control $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->sourcePairs = $this->doc->getFileSourcePairs($files); - $this->view->fileIcon = $this->doc->getFileIcon($files); $this->view->libTree = $this->doc->getLibTree(0, $libs, $type, 0, $objectID); $this->view->objectDropdown = $objectDropdown; $this->view->searchTitle = $searchTitle; diff --git a/module/doc/ui/showfiles.html.php b/module/doc/ui/showfiles.html.php index f3623b8aa5..736e084b25 100644 --- a/module/doc/ui/showfiles.html.php +++ b/module/doc/ui/showfiles.html.php @@ -17,32 +17,6 @@ jsVar('+searchLink', createLink('doc', 'showFiles', "type={$type}&objectID={$obj $filesBody = null; if($viewType == 'list') { - foreach($files as $fileID => $file) - { - if(empty($file->pathname)) - { - unset($files[$fileID]); - continue; - } - - $file->fileIcon = $fileIcon[$file->id] ; - $file->fileName = str_replace('.' . $file->extension, '', $file->title); - $file->sourceName = isset($sourcePairs[$file->objectType][$file->objectID]) ? $sourcePairs[$file->objectType][$file->objectID] : ''; - $file->sizeText = number_format($file->size / 1024, 1) . 'K'; - - $imageSize = $this->file->getImageSize($file); - $file->imageWidth = isset($imageSize[0]) ? $imageSize[0] : 0; - if($file->objectType == 'requirement') - { - $file->objectName = $lang->URCommon . ' : '; - } - else - { - if(!isset($lang->{$file->objectType}->common)) $app->loadLang($file->objectType); - $file->objectName = $lang->{$file->objectType}->common . ' : '; - } - } - if(!empty($files)) { $tableData = initTableData($files, $config->doc->showfiles->dtable->fieldList); diff --git a/module/doc/zen.php b/module/doc/zen.php new file mode 100644 index 0000000000..9592bd9522 --- /dev/null +++ b/module/doc/zen.php @@ -0,0 +1,54 @@ + + * @package doc + * @link https://www.zentao.net + */ +class docZen extends doc +{ + /** + * Process file field for table. + * + * @param array $files + * @param array $fileIcon + * @param array $sourcePairs + * @access protected + * @return arary + */ + protected function processFiles(array $files, array $fileIcon, array $sourcePairs): array + { + $this->loadModel('file'); + foreach($files as $fileID => $file) + { + if(empty($file->pathname)) + { + unset($files[$fileID]); + continue; + } + + $file->fileIcon = isset($fileIcon[$file->id]) ? $fileIcon[$file->id] : ''; + $file->fileName = str_replace('.' . $file->extension, '', $file->title); + $file->sourceName = isset($sourcePairs[$file->objectType][$file->objectID]) ? $sourcePairs[$file->objectType][$file->objectID] : ''; + $file->sizeText = number_format($file->size / 1024, 1) . 'K'; + + $imageSize = $this->file->getImageSize($file); + $file->imageWidth = isset($imageSize[0]) ? $imageSize[0] : 0; + if($file->objectType == 'requirement') + { + $file->objectName = $this->lang->URCommon . ' : '; + } + else + { + if(!isset($this->lang->{$file->objectType}->common)) $this->app->loadLang($file->objectType); + $file->objectName = $this->lang->{$file->objectType}->common . ' : '; + } + } + return $files; + } +} +