diff --git a/module/search/control.php b/module/search/control.php index 734118ab85..75d932cbf6 100644 --- a/module/search/control.php +++ b/module/search/control.php @@ -202,9 +202,11 @@ class search extends control $type = (empty($type) or $type[0] == 'all') ? 'all' : $type; $this->app->loadClass('pager', $static = true); - $pager = new pager($recTotal, $this->config->search->recPerPage, $pageID); - $begin = time(); - $result = $this->search->getList($words, $pager, $type); + $begin = time(); + $results = $this->search->getList($words, $type); + $recTotal = count($results); + $pager = new pager($recTotal, $this->config->search->recPerPage, $pageID); + $results = array_chunk($results, $pager->recPerPage); /* Set session. */ $uri = inlink('index', "recTotal=$pager->recTotal&pageID=$pager->pageID"); @@ -237,7 +239,7 @@ class search extends control if(strpos($this->server->http_referer, 'search') === false) $this->session->set('referer', $this->server->http_referer); - $this->view->results = $result; + $this->view->results = empty($results) ? $results : $results[$pageID - 1]; $this->view->consumed = time() - $begin; $this->view->title = $this->lang->search->index; $this->view->type = $type; diff --git a/module/search/model.php b/module/search/model.php index 737e7afc66..e886f4d1fb 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -499,12 +499,11 @@ class searchModel extends model * get search results of keywords. * * @param string $keywords - * @param object $pager * @param string $type * @access public * @return array */ - public function getList($keywords, $pager, $type) + public function getList($keywords, $type) { $spliter = $this->app->loadClass('spliter'); $words = explode(' ', self::unify($keywords, ' ')); @@ -557,7 +556,6 @@ class searchModel extends model ->andWhere('objectType')->in($allowedObject) ->andWhere('addedDate')->le(helper::now()) ->orderBy('score_desc, editedDate_desc') - ->page($pager) ->fetchAll('id'); foreach($results as $record) @@ -643,7 +641,7 @@ class searchModel extends model } } - return $this->checkPriv($results, $pager); + return $this->checkPriv($results); } /** @@ -775,11 +773,10 @@ class searchModel extends model * Check product and project priv. * * @param array $results - * @param object $pager * @access public * @return array */ - public function checkPriv($results, $pager = null) + public function checkPriv($results) { if($this->app->user->admin) return $results; @@ -931,7 +928,6 @@ class searchModel extends model } } } - if($total != count($results)) $pager->recTotal = $pager->recTotal - ($total - count($results)); return $results; }