From ffc05df649be75b4c9260fbc80e514696bfb4cb7 Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Wed, 28 Jul 2021 09:31:14 +0800 Subject: [PATCH] * Task#40529,#40530. --- module/doc/control.php | 109 +++++++++++++++++++- module/doc/lang/zh-cn.php | 9 +- module/doc/model.php | 137 ++++++++++++++++++++++++- module/doc/view/showfiles.html.php | 158 +++++++++++++++++++++++++++++ 4 files changed, 407 insertions(+), 6 deletions(-) create mode 100644 module/doc/view/showfiles.html.php diff --git a/module/doc/control.php b/module/doc/control.php index 79eed2d430..302ecae9cb 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -744,6 +744,112 @@ class doc extends control die($select); } + /** + * Show files. + * + * @param string $type + * @param int $objectID + * @param string $viewType + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * @access public + * @return void + */ + public function showFiles($type, $objectID, $viewType = '', $orderBy = 't1.id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + { + $uri = $this->app->getURI(true); + $this->app->session->set('taskList', $uri); + $this->app->session->set('storyList', $uri); + $this->app->session->set('docList', $uri); + + if(empty($viewType)) $viewType = !empty($_COOKIE['docFilesViewType']) ? $this->cookie->docFilesViewType : 'card'; + setcookie('docFilesViewType', $viewType, $this->config->cookieLife, $this->config->webRoot, '', false, true); + + $objects = $this->doc->getOrderedObjects($type); + if($type == 'product') + { + $objectID = $this->product->saveState($objectID, $objects); + $table = TABLE_PRODUCT; + + $libs = $this->doc->getLibsByObject('product', $objectID); + + $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs); + + $this->app->rawMethod = 'product'; + } + else if($type == 'project') + { + $objectID = $this->project->saveState($objectID, $objects); + $table = TABLE_PROJECT; + + $libs = $this->doc->getLibsByObject('project', $objectID); + + $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs); + + $this->app->rawMethod = 'project'; + } + else if($type == 'execution') + { + $objectID = $this->execution->saveState($objectID, $objects); + $table = TABLE_EXECUTION; + $libs = $this->doc->getLibsByObject('execution', $objectID); + + $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs); + + $this->app->rawMethod = 'execution'; + } + + $openApp = strpos('doc,product,project,execution', $this->app->openApp) !== false ? $this->app->openApp : 'doc'; + if($openApp != 'doc') $this->loadModel($openApp)->setMenu($objectID); + + $table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT; + $object = $this->dao->select('id,name,status')->from($table)->where('id')->eq($objectID)->fetch(); + + $this->lang->TRActions = $this->doc->buildCollectButton4Doc(); + $this->lang->TRActions .= $this->doc->buildBrowseSwitch($type, $objectID, $viewType); + + /* Load pager. */ + $this->app->loadClass('pager', $static = true); + $pager = new pager($recTotal, $recPerPage, $pageID); + + $files = $this->doc->getLibFiles($type, $objectID, $orderBy, $pager); + + $this->view->title = $object->name; + $this->view->position[] = $object->name; + + $this->view->type = $type; + $this->view->object = $object; + $this->view->files = $files; + $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->sourcePairs = $this->doc->getFileSourcePairs($files); + $this->view->fileIcon = $this->doc->getFileIcon($files); + + $this->display(); + } + + /** + * Batch download. + * + * @access public + * @return void + */ + public function batchDownload() + { + $this->loadModel('file'); + $fileIDList = $this->post->fileIDList; + foreach($fileIDList as $fileID) + { + } + } + /** * Show all libs by type. * @@ -1050,7 +1156,8 @@ class doc extends control $openApp = strpos('doc,product,project,execution', $this->app->openApp) !== false ? $this->app->openApp : 'doc'; if($openApp != 'doc') $this->loadModel($openApp)->setMenu($objectID); - $this->lang->TRActions = common::hasPriv('doc', 'create') ? $this->doc->buildCreateButton4Doc($type, $objectID, $libID) : ''; + $this->lang->TRActions = $this->doc->buildCollectButton4Doc(); + $this->lang->TRActions .= common::hasPriv('doc', 'create') ? $this->doc->buildCreateButton4Doc($type, $objectID, $libID) : ''; $moduleTree = $type == 'book' ? $this->doc->getBookStructure($libID) : $this->doc->getTreeMenu($type, $objectID, $libID); diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index 00413b84c0..2e6ca3cd26 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -11,7 +11,7 @@ */ /* 字段列表。*/ $lang->doc->common = '文档'; -$lang->doc->id = '文档编号'; +$lang->doc->id = '编号'; $lang->doc->product = '所属' . $lang->productCommon; $lang->doc->project = '所属项目'; $lang->doc->execution = '所属' . $lang->executionCommon; @@ -36,10 +36,11 @@ $lang->doc->fileObject = '所属对象'; $lang->doc->whiteList = '白名单'; $lang->doc->contentType = '文档格式'; $lang->doc->separator = ""; -$lang->doc->fileTitle = '附件名'; +$lang->doc->fileTitle = '附件名称'; $lang->doc->filePath = '地址'; $lang->doc->extension = '类型'; $lang->doc->size = '附件大小'; +$lang->doc->source = '来源'; $lang->doc->download = '下载'; $lang->doc->acl = '权限'; $lang->doc->fileName = '附件'; @@ -217,6 +218,10 @@ $lang->doc->noticeAcl['doc']['private'] = '只有创建者自己可以访问。' $lang->doc->placeholder = new stdclass(); $lang->doc->placeholder->url = '相应的链接地址'; +$lang->doc->summary = "本页共 %s 个附件,共计 %s,其中%s。"; +$lang->doc->ge = '个'; +$lang->doc->point = '、'; + $lang->doclib = new stdclass(); $lang->doclib->name = '文档库名称'; $lang->doclib->control = '访问控制'; diff --git a/module/doc/model.php b/module/doc/model.php index 70935fdc6e..209c0d95aa 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1392,6 +1392,65 @@ class docModel extends model return $files; } + /** + * Get file source pairs. + * + * @param array $files + * @access public + * @return array + */ + public function getFileSourcePairs($files) + { + $sourceList = array(); + $sourcePairs = array(); + + foreach($files as $file) + { + if(!isset($sourceList[$file->objectType])) $sourceList[$file->objectType] = array(); + $sourceList[$file->objectType][$file->objectID] = $file->objectID; + } + + foreach($sourceList as $type => $idList) + { + $table = $this->config->objectTables[$type]; + $title = $type == 'task' ? 'name' : 'title'; + $name = $this->dao->select('id,' . $title)->from($table)->where('id')->in($idList)->fetchPairs('id'); + $sourcePairs[$type] = $name; + } + + return $sourcePairs; + } + + /** + * Get file icon. + * + * @param array $files + * @access public + * @return array + */ + public function getFileIcon($files) + { + foreach($files as $file) + { + if(in_array($file->extension, $this->config->file->imageExtensions)) continue; + + $iconClass = 'icon-file'; + if(strpos('zip,tar,gz,bz2,rar', $file->extension) !== false) $iconClass = 'icon-file-archive'; + else if(strpos('csv,xls,xlsx', $file->extension) !== false) $iconClass = 'icon-file-excel'; + else if(strpos('doc,docx', $file->extension) !== false) $iconClass = 'icon-file-word'; + else if(strpos('ppt,pptx', $file->extension) !== false) $iconClass = 'icon-file-powerpoint'; + else if(strpos('pdf', $file->extension) !== false) $iconClass = 'icon-file-pdf'; + else if(strpos('mp3,ogg,wav', $file->extension) !== false) $iconClass = 'icon-file-audio'; + else if(strpos('avi,mp4,mov', $file->extension) !== false) $iconClass = 'icon-file-video'; + else if(strpos('txt,md', $file->extension) !== false) $iconClass = 'icon-file-text'; + else if(strpos('html,htm', $file->extension) !== false) $iconClass = 'icon-globe'; + + $fileIcon[$file->id] = ""; + } + + return $fileIcon; + } + /** * Get doc tree. * @@ -1774,6 +1833,25 @@ class docModel extends model return $html; } + /** + * Build browse switch button. + * + * @param int $type + * @param int $objectID + * @param int $viewType + * @access public + * @return void + */ + public function buildBrowseSwitch($type, $objectID, $viewType) + { + $html = "
"; + $html .= html::a(inlink('showFiles', "type=$type&objectID=$objectID&viewType=card"), "", '', "title={$this->lang->doc->browseTypeList['grid']} class='btn btn-icon" . ($viewType != 'list' ? ' text-primary' : '') . "'"); + $html .= html::a(inlink('showFiles', "type=$type&objectID=$objectID&viewType=list"), "" , '', "title={$this->lang->doc->browseTypeList['list']} class='btn btn-icon" . ($viewType == 'list' ? ' text-primary' : '') . "'"); + $html .= "
"; + + return $html; + } + /** * Set past menu. * @@ -1928,7 +2006,7 @@ class docModel extends model $class = ($type == 'project' and $this->app->openApp == 'doc') ? 'col-left' : ''; $currentMethod = $this->app->getMethodName(); - $methodName = $currentMethod == 'tablecontents' ? 'tablecontents' : 'objectLibs'; + $methodName = in_array($currentMethod, array('tablecontents', 'showfiles')) ? 'tablecontents' : 'objectLibs'; if($this->app->openApp == 'doc' and $type != 'custom' and $type != 'book') { @@ -1965,7 +2043,8 @@ class docModel extends model if(!empty($libs)) { - $output .= "
+ + + +