示例#1
0
 public function defaultAction()
 {
     $result['image'] = true;
     $result['top_image'] = IndexPageConfig::$IMAGE_TOP;
     $this->orgWord = HttpNamespace::getGET('kw');
     $this->typeId = HttpNamespace::getGET('type');
     $this->params['query'] = $this->orgWord;
     //搜索作者
     if ($this->typeId == 'author') {
         $this->params['author'] = true;
         //通过uid搜索作者
     } elseif (strtolower($this->typeId) == 'uid') {
         $user = UserNamespace::getUserById($this->orgWord);
         if ($user) {
             $this->params['uid'] = true;
             $this->params['username'] = $user['nick_name'];
             $this->orgWord = $this->params['username'];
         }
         //搜索日记本通过id
     } elseif (strtolower($this->typeId) == 'bookid') {
         $this->params['bookid'] = true;
         $book = DiaryBookNamespace::getUserById($this->orgWord);
         if ($book) {
             $this->params['diarybook'] = $book['book_name'];
             $this->orgWord = $this->params['diarybook'];
         }
         //搜索日记本通过kw
     } elseif (strtolower($this->typeId) == 'bookname') {
         $this->params['bookname'] = true;
         //搜索个关键词
     } else {
         $this->typeId = (int) $this->typeId;
         $pa = CategoryNamespace::getById($this->typeId);
         $this->type = $pa['type'];
         $this->params[$pa['type']] = $pa;
     }
     $page = HttpNamespace::getGET('p');
     list($result['article'], $result['count'], $this->cutWord) = DBXapian::searchByQuery($this->params, $page, self::$PAGE_SIZE);
     $result['cutword'] = $this->createUrlByWord($this->cutWord);
     $result['kw'] = $this->orgWord;
     $result['title'] = $this->orgWord;
     $result['type_id'] = $this->typeId;
     $result['page'] = $this->_showPage($result['count']);
     $this->assign($result);
     $this->display();
 }