diff --git a/module/doc/control.php b/module/doc/control.php index 9f6a58abb5..0c5de5bbaf 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,15 @@ 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 * @access public * @return void */ - public function tableContents($type, $objectID = 0, $libID = 0) + public function tableContents($type, $objectID = 0, $libID = 0, $queryID = 0, $param = '') { list($libs, $libID, $object, $objectID) = $this->doc->setMenuByType($type, $objectID, $libID); $this->session->set('createProjectLocate', $this->app->getURI(true), 'doc'); @@ -1168,15 +1170,39 @@ class doc extends control $title = ($type == 'book' or $type == 'custom') ? $this->lang->doc->tableContents : $object->name . $this->lang->colon . $this->lang->doc->tableContents; - $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->users = $this->user->getPairs('noletter'); + /* 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->display(); + if($param == 'bySearch') + { + /* Load pager. */ + $this->app->loadClass('pager', $static = true); + $pager = new pager(0, 20, 1); + + $this->view->docs = $this->doc->getDocsBySearch($type, $objectID, $libID, $queryID); + $this->view->browseType = 'bySearch'; + $this->view->pager = $pager; + $this->view->param = $param; + $this->view->type = $type; + $this->view->users = $this->user->getPairs('noletter'); + $this->display('doc', 'browse', "browseType=bySearch¶m=$queryID"); + } + else + { + $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->queryID = $queryID; + $this->view->param = $param; + $this->view->users = $this->user->getPairs('noletter'); + + $this->display(); + } } /** 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..92bdb5fefb 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( { diff --git a/module/doc/model.php b/module/doc/model.php index 7fe3134a2a..4a9ceddf2a 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -931,19 +931,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); @@ -1638,7 +1648,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(); @@ -1699,7 +1709,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'); @@ -2140,8 +2150,19 @@ class docModel extends model ->orderBy('t1.id_desc') ->limit($favoritesLimit) ->fetchAll(); - - $html = "