Author: Han Tianfeng
Exemple #1
0
 function search()
 {
     if (isset($_GET['prid'])) {
         $this->project_id = intval($_GET['prid']);
     } else {
         $this->project_id = 1;
     }
     if (empty($_GET['q'])) {
         return "请输入搜索的关键词";
     }
     $this->getProjectInfo();
     $this->getProjectLinks();
     $this->getTreeData();
     $_GET['id'] = $this->project['home_id'];
     $pagesize = 10;
     $page = empty($_GET['page']) ? 1 : intval($_GET['page']);
     $xs = new \XS(WEBPATH . '/search.ini');
     $search = $xs->getSearch();
     $q = trim($_GET['q']);
     $search->setQuery($q);
     $total = $search->count();
     if ($page * $pagesize > $total) {
         $page = 1;
     }
     $search->setLimit($pagesize, ($page - 1) * $pagesize);
     $pager = new Swoole\Pager(array('page' => $page, 'perpage' => $pagesize, 'total' => $total));
     $docs = $search->search();
     $list = array();
     foreach ($docs as $doc) {
         $li['id'] = $doc->pid;
         $li['title'] = $doc->subject;
         $li['desc'] = $doc->message;
         $list[] = $li;
     }
     $pager->page_tpl = "/wiki/search/?q=" . urlencode($_GET['q']) . '&page=%s';
     $this->tpl->assign('list', $list);
     $this->tpl->assign('pager', $pager->render());
     $this->tpl->display("wiki/noframe/search.html");
 }
Exemple #2
0
 function search()
 {
     $keyword = mb_substr(trim($_GET['k']), 0, 32);
     if (empty($keyword)) {
         Swoole\JS::js_back('关键词不能为空!');
         exit;
     }
     $page = empty($_GET['page']) ? 1 : (int) $_GET['page'];
     $res = $this->fulltext($keyword, $page);
     $pager = new Swoole\Pager(array('page' => $page, 'perpage' => $this->pagesize, 'total' => $res['total']));
     $this->swoole->tpl->assign('pager', array('total' => $pager->total, 'render' => $pager->render()));
     $this->swoole->tpl->assign('forms', $_forms);
     $this->swoole->tpl->assign("list", $res['list']);
     $this->swoole->tpl->display();
 }