Exemplo n.º 1
0
 public function userAction()
 {
     if (($result = $this->_checkRight()) instanceof PwError) {
         $this->showError($result->getError());
     }
     list($page, $perpage, $keywords, $limittime, $orderby) = $this->getInput(array('page', 'perpage', 'keywords', 'limittime', 'orderby'));
     $args = array();
     if ($keywords) {
         //最后搜索时间
         if (($result = $this->_checkSearch()) instanceof PwError) {
             $this->showError($result->getError());
         }
         $page = $page ? $page : 1;
         $perpage = $perpage ? $perpage : $this->perpage;
         list($start, $limit) = Pw::page2limit($page, $perpage);
         Wind::import('SRV:user.vo.PwUserSo');
         $keywords = urldecode($keywords);
         $so = new PwUserSo();
         $so->setUsername($keywords)->orderbyLastpost(0);
         $limittime && $so->setRegdate($this->_getLimitTime($limittime));
         $count = $this->_getSearchService()->countSearchUser($so);
         $count = $count > $this->maxNum ? $this->maxNum : $count;
         if ($count) {
             $users = $this->_getSearchService()->searchUser($so, $limit, $start);
             $users = $this->_getSearchService()->buildUsers($users, $keywords);
             $uids = array_keys($users);
             $follows = Wekit::load('attention.PwAttention')->fetchFollows($this->loginUser->uid, $uids);
             $fans = Wekit::load('attention.PwAttention')->fetchFans($this->loginUser->uid, $uids);
             $friends = array_intersect_key($fans, $follows);
             $this->setOutput($fans, 'fans');
             $this->setOutput($friends, 'friends');
             $this->setOutput($follows, 'follows');
             $this->_replaceRecord($keywords, App_Search_Record::TYPE_USER);
         }
         $this->setOutput($page, 'page');
         $this->setOutput($perpage, 'perpage');
         $this->setOutput($count, 'count');
         $this->setOutput(array('keywords' => $keywords), 'args');
         $this->setOutput($users, 'users');
     }
     $this->setOutput(App_Search_Record::TYPE_USER, 'recordType');
     $this->setTemplate('index_user');
     //seo设置
     $seoBo->setCustomSeo($keywords . ' - {sitename}', '', '');
 }