diff --git a/module/doc/control.php b/module/doc/control.php index 2e4261d9a8..7518a34a81 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -896,13 +896,13 @@ class doc extends control /** * Show files. * - * @param string $type - * @param int $objectID - * @param string $viewType - * @param string $orderBy - * @param int $recTotal - * @param int $recPerPage - * @param int $pageID + * @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 */ @@ -1151,13 +1151,18 @@ class doc extends control /** * Show the catalog of the doc library. * - * @param string $type - * @param int $objectID - * @param int $libID + * @param string $type + * @param int $objectID + * @param int $libID + * @param int $queryID + * @param string $param + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ - public function tableContents($type, $objectID = 0, $libID = 0) + public function tableContents($type, $objectID = 0, $libID = 0, $queryID = 0, $param = '', $recTotal = 0, $recPerPage = 20, $pageID = 1) { list($libs, $libID, $object, $objectID) = $this->doc->setMenuByType($type, $objectID, $libID); $this->session->set('createProjectLocate', $this->app->getURI(true), 'doc'); @@ -1168,15 +1173,39 @@ class doc extends control $title = ($type == 'book' or $type == 'custom') ? $this->lang->doc->tableContents : $object->name . $this->lang->colon . $this->lang->doc->tableContents; + /* Build the search form. */ + $queryID = $param == 'bySearch' ? (int)$queryID : 0; + $actionURL = $this->createLink('doc', 'tableContents', "type=$type&objectID=$objectID&libID=$libID&queryID=myQueryID¶m=bySearch"); + $this->doc->buildSearchForm($libID, $libs, $queryID, $actionURL, $type); + $this->view->title = $title; $this->view->type = $type; - $this->view->libs = $libs; - $this->view->objectID = $objectID; - $this->view->libID = $libID; - $this->view->moduleTree = $moduleTree; + $this->view->param = $param; + $this->view->queryID = $queryID; $this->view->users = $this->user->getPairs('noletter'); + if($param == 'bySearch') + { + /* Load pager. */ + $rawMethod = $this->app->rawMethod; + $this->app->rawMethod = 'tableContents'; + $this->app->loadClass('pager', $static = true); + $pager = new pager($recTotal, $recPerPage, $pageID); + $this->app->rawMethod = $rawMethod; - $this->display(); + $this->view->docs = $this->doc->getDocsBySearch($type, $objectID, $libID, $queryID, $pager); + $this->view->browseType = 'bySearch'; + $this->view->pager = $pager; + $this->display('doc', 'browse', "browseType=bySearch¶m=$queryID"); + } + else + { + $this->view->libs = $libs; + $this->view->objectID = $objectID; + $this->view->libID = $libID; + $this->view->moduleTree = $moduleTree; + + $this->display(); + } } /** diff --git a/module/doc/css/browse.css b/module/doc/css/browse.css index d52cf2e338..9f08480a4a 100644 --- a/module/doc/css/browse.css +++ b/module/doc/css/browse.css @@ -1 +1,2 @@ -#pageActions ul.dropdown-menu {left: 67px !important;} +#mainContent .c-id {width: 70px;} +#mainContent .c-id > a {color: #0c60e1;} diff --git a/module/doc/js/browse.js b/module/doc/js/browse.js index 7069c7e805..65771d2363 100644 --- a/module/doc/js/browse.js +++ b/module/doc/js/browse.js @@ -5,3 +5,7 @@ $('.ajaxCollect').click(function() window.location.reload(); } }) +$(function() +{ + $('#pageActions .btn-toolbar').prepend("" + docLang.search + ""); +}); diff --git a/module/doc/js/tablecontents.js b/module/doc/js/tablecontents.js index d11c77d92a..0e2a340b24 100644 --- a/module/doc/js/tablecontents.js +++ b/module/doc/js/tablecontents.js @@ -19,6 +19,8 @@ $(function() $('.menu-actions > a').blur(function() {$(this).css('background', 'none');}) + $('#pageActions .btn-toolbar').prepend("" + docLang.search + ""); + /* Make modules tree sortable. */ $('#modules').sortable( { @@ -96,3 +98,7 @@ $(function() } }); }) +$(document).on("click", '#bysearchTab', function() +{ + $('.main-content > .cell > .detail > .menu-actions').remove(); +}); diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index b879716bfd..ddbd9cea78 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -45,7 +45,7 @@ $lang->doclib->nameList['custom'] = '自定义文档库名称'; /* 字段列表。*/ $lang->doc->common = '文档'; -$lang->doc->id = '编号'; +$lang->doc->id = '文档编号'; $lang->doc->product = '所属' . $lang->productCommon; $lang->doc->project = '所属项目'; $lang->doc->execution = '所属' . $lang->execution->common; diff --git a/module/doc/model.php b/module/doc/model.php index 6527b467d5..b9015e4f75 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -932,19 +932,29 @@ class docModel extends model $this->config->doc->search['params']['project']['values'] = array('' => '') + $this->loadModel('project')->getPairsByProgram() + array('all' => $this->lang->doc->allProjects); $this->config->doc->search['params']['execution']['values'] = array('' => '') + $this->loadModel('execution')->getPairs() + array('all' => $this->lang->doc->allExecutions); $this->config->doc->search['params']['lib']['values'] = array('' => '') + $this->loadModel('doc')->getLibs('all', 'withObject') + array('all' => $this->lang->doclib->all); + $this->config->doc->search['params']['product']['values'] = array('' => '') + $products + array('all' => $this->lang->doc->allProduct); unset($this->config->doc->search['fields']['module']); } + elseif(in_array($type, array('product', 'project', 'execution', 'custom', 'book'))) + { + $queryName = $type . 'Doc'; + $this->config->doc->search['module'] = $queryName; + $this->config->doc->search['params']['lib']['values'] = array('' => '', $libID => (isset($libs[$libID]) ? $libs[$libID]->name : $libID), 'all' => $this->lang->doclib->all); + unset($this->config->doc->search['fields']['product']); + unset($this->config->doc->search['fields']['execution']); + unset($this->config->doc->search['fields']['module']); + } else { $products = $this->product->getPairs('nocode', $this->session->project); $this->config->doc->search['params']['execution']['values'] = array('' => '') + $this->loadModel('execution')->getPairs($this->session->project, 'all', 'noclosed') + array('all' => $this->lang->doc->allExecutions); $this->config->doc->search['params']['lib']['values'] = array('' => '', $libID => ($libID ? $libs[$libID] : 0), 'all' => $this->lang->doclib->all); + $this->config->doc->search['params']['product']['values'] = array('' => '') + $products + array('all' => $this->lang->doc->allProduct); } - $this->config->doc->search['actionURL'] = $actionURL; - $this->config->doc->search['queryID'] = $queryID; - $this->config->doc->search['params']['product']['values'] = array('' => '') + $products + array('all' => $this->lang->doc->allProduct); + $this->config->doc->search['actionURL'] = $actionURL; + $this->config->doc->search['queryID'] = $queryID; /* Get the modules. */ $moduleOptionMenu = $this->loadModel('tree')->getOptionMenu($libID, 'doc', $startModuleID = 0); @@ -1639,7 +1649,7 @@ class docModel extends model $idList = array_keys($docs); $docIdList = $this->dao->select('id')->from(TABLE_DOC)->where($type)->eq($objectID)->andWhere('id')->in($idList)->get(); - $searchTitle = $this->get->title; + $searchTitle = $this->post->title; if($type == 'product') { $storyIdList = $this->dao->select('id')->from(TABLE_STORY)->where('product')->eq($objectID)->andWhere('deleted')->eq('0')->andWhere('product')->in($userView)->get(); @@ -1700,7 +1710,7 @@ class docModel extends model ->orWhere("(objectType = 'build' and objectID in ($buildIdList))") ->fi() ->markRight(1) - ->beginIF($searchTitle)->andWhere('title')->like("%{$searchTitle}%")->fi() + ->beginIF($searchTitle !== false)->andWhere('title')->like("%{$searchTitle}%")->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); @@ -2141,8 +2151,19 @@ class docModel extends model ->orderBy('t1.id_desc') ->limit($favoritesLimit) ->fetchAll(); - - $html = "
"; + if($this->app->rawMethod == 'showfiles') + { + $html = '
'; + $html .= '
'; + $html .= html::input('title', $this->post->title, "class='form-control' placeholder='{$this->lang->doc->fileTitle}'"); + $html .= html::submitButton("", '', "btn btn-icon btn-link input-control-icon-right"); + $html .= '
'; + } + else + { + $html = ''; + } + $html .= "
"; $html .= "{$this->lang->doc->myCollection}"; $html .= "
    "; @@ -2819,6 +2840,94 @@ EOT; return $autoloadPage; } + /** + * Get docs by search. + * + * @param string $type + * @param int $objectID + * @param int $libID + * @param int $queryID + * @param object $pager + * + * @access public + * @return array + */ + public function getDocsBySearch($type, $objectID, $libID, $queryID, $pager) + { + $queryName = $type . 'DocQuery'; + $queryForm = $type . 'DocForm'; + if($queryID) + { + $query = $this->loadModel('search')->getQuery($queryID); + if($query) + { + $this->session->set($queryName, $query->sql); + $this->session->set($queryForm, $query->form); + } + else + { + $this->session->set($queryName, ' 1 = 1'); + } + } + else + { + if($this->session->$queryName == false) $this->session->set($queryName, ' 1 = 1'); + } + + $libs = $this->getLibsByObject($type, $objectID); + $query = $this->session->$queryName; + $docs = $this->dao->select('*')->from(TABLE_DOC) + ->where('deleted')->eq(0) + ->andWhere(str_replace("`lib` = 'all'", '1', $query)) + ->beginIF(strpos($query, "`lib` = 'all'") === false)->andWhere('lib')->eq($libID)->fi() + ->andWhere('lib')->in(array_keys($libs)) + ->beginIF($this->config->doc->notArticleType)->andWhere('type')->notIN($this->config->doc->notArticleType)->fi() + ->orderBy('id_desc') + ->page($pager) + ->fetchAll('id'); + + $docContents = $this->dao->select('*')->from(TABLE_DOCCONTENT)->where('doc')->in(array_keys($docs))->orderBy('version,doc')->fetchAll('doc'); + + $files = $this->dao->select('*')->from(TABLE_FILE) + ->where('objectType')->eq('doc') + ->andWhere('objectID')->in(array_keys($docs)) + ->fetchGroup('objectID'); + foreach($docs as $docID => $doc) + { + $docs[$docID]->fileSize = 0; + if(isset($files[$docID])) + { + $docContent = $docContents[$docID]; + $fileSize = 0; + foreach($files[$docID] as $file) + { + if(strpos(",{$docContent->files},", ",{$file->id},") === false) continue; + $fileSize += $file->size; + } + + if($fileSize < 1024) + { + $fileSize .= 'B'; + } + elseif($fileSize < 1024 * 1024) + { + $fileSize = round($fileSize / 1024, 2) . 'KB'; + } + elseif($fileSize < 1024 * 1024 * 1024) + { + $fileSize = round($fileSize / 1024 / 1024, 2) . 'MB'; + } + else + { + $fileSize = round($fileSize / 1024 / 1024 / 1024, 2) . 'G'; + } + + $docs[$docID]->fileSize = $fileSize; + } + } + return $docs; + } + /** * Update Lib orders. * diff --git a/module/doc/view/browse.html.php b/module/doc/view/browse.html.php index 1d09883c89..deb343f017 100644 --- a/module/doc/view/browse.html.php +++ b/module/doc/view/browse.html.php @@ -13,7 +13,11 @@ +doc);?> doc->confirmDelete)?> + +
    >
    +
    @@ -26,8 +30,13 @@ + + + + + @@ -40,6 +49,7 @@ collector, ',' . $this->app->user->account . ',') !== false ? 'icon-star text-yellow' : 'icon-star-empty';?> collector, ',' . $this->app->user->account . ',') !== false ? $lang->doc->cancelCollection : $lang->doc->collect;?> + @@ -54,6 +64,15 @@ } ?> + + + + + + + + + diff --git a/module/doc/view/edit.html.php b/module/doc/view/edit.html.php index bb1a1fa5d7..3abdafad4b 100644 --- a/module/doc/view/edit.html.php +++ b/module/doc/view/edit.html.php @@ -26,7 +26,6 @@ createLink('doc', 'view', "docID=$doc->id"), $doc->title, '', "title='$doc->title'");?> arrow . ' ' . $lang->doc->edit;?> -
    save, '', 'id="top-submit" class="btn btn-primary"');?>
    doc->title;?> doc->object;?>doc->id;?>doc->title;?> doc->size;?> doc->addedBy;?> doc->addedDate;?>
    createLink('doc', 'view', "docID=$doc->id&version=0", '', true), "  " . $doc->title, '', "title='{$doc->title}' class='iframe' data-width='90%'");?> createLink('doc', 'view', "docID=$doc->id&version=0", '', true), $doc->id, '', "title='{$doc->id}' class='iframe' data-width='90%'");?>createLink('doc', 'view', "docID=$doc->id&version=0", '', true), "  " . $doc->title, '', "title='{$doc->title}' class='iframe' data-width='90%'");?> {$doc->id}";?> {$doc->title}";?> fileSize ? $doc->fileSize : '-';?> addedBy);?> addedDate, 'y-m-d');?>
    diff --git a/module/doc/view/tablecontents.html.php b/module/doc/view/tablecontents.html.php index e7941a936b..5935ef3acf 100644 --- a/module/doc/view/tablecontents.html.php +++ b/module/doc/view/tablecontents.html.php @@ -12,6 +12,7 @@ ?> +doc);?> doclib->tabList as $libType => $typeName) $sideLibs[$libType] = $this->doc->getLimitLibs($libType); @@ -27,6 +28,7 @@ if($this->methodName != 'browse') } if(empty($type)) $type = 'product'; ?> +
    >