public function run() { $page = $this->getInput('page'); $this->page = $page < 1 ? 1 : intval($page); list($start, $limit) = Pw::page2limit($this->page, $this->perpage); $timestamp = PW::getTime(); $startTime = $timestamp - 7 * 86400; $endTime = $timestamp; $total = $this->_getPollDs()->countPollByTime($startTime, $endTime); $pollInfo = array(); if ($total) { Wind::import('SRV:poll.srv.dataSource.PwFetchPollByTime'); $pollDisplay = new PwPollDisplay(new PwFetchPollByTime($startTime, $endTime, $limit, $start, array('voter_num' => 0, 'created_time' => 0))); $pollInfo = $this->_buildPoll($pollDisplay->gather()); } $latestPollDisplay = new PwPollDisplay(new PwFetchPollByOrder(10, 0, array('created_time' => '0'))); $latestPoll = $latestPollDisplay->gather(); $this->setOutput($total, 'total'); $this->setOutput($pollInfo, 'pollInfo'); $this->setOutput($latestPoll, 'latestPoll'); $this->setOutput($this->page, 'page'); $this->setOutput($this->perpage, 'perpage'); $this->setOutput(array('allowview' => $this->loginUser->getPermission('allow_view_vote'), 'allowvote' => $this->loginUser->getPermission('allow_participate_vote')), 'pollGroup'); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); if ($this->page > 1) { $seoBo->setCustomSeo($lang->getMessage('SEO:vote.hot.run.page.title', array($this->page)), $lang->getMessage('vote.hot.run.description'), ''); } else { $seoBo->setCustomSeo($lang->getMessage('SEO:vote.hot.run.title'), '', $lang->getMessage('SEO:vote.hot.run.description')); } Wekit::setV('seo', $seoBo); }
/** * 添加草稿 * * @return void */ public function doAddAction() { list($title, $content) = $this->getInput(array('atc_title', 'atc_content')); if (!$title || !$content) { $this->showError('BBS:draft.content.empty'); } if ($this->_getDraftDs()->countByUid($this->loginUser->uid) >= $this->maxNum) { $this->showError('BBS:draft.num.max'); } $draftDm = new PwDraftDm(); $draftDm->setTitle($title)->setContent($content)->setCreatedUserid($this->loginUser->uid)->setCreatedTime(PW::getTime()); $this->_getDraftDs()->addDraft($draftDm); $this->showMessage('success'); }
/** * 获取某个生活服务版块下的帖子列表 * @access public * @return string <pre> /index.php?m=native&c=life&a=life&fid=生活服务分类id&page=1&_json=1 response: </pre> */ public function lifeAction() { list($page, $fid) = $this->getInput(array('page', 'fid'), 'get'); !$fid && $this->showError('NATIVE:args.error'); $page = intval($page) > 1 ? intval($page) : 1; $pos = ($page - 1) * $this->perpage; //获取单个版块信息 $forum = Wekit::loadDao('forum.dao.PwForumDao')->getForum($fid); $forum_life = Wekit::loadDao('native.dao.PwForumLifeDao')->getForumLife($fid); $forum['address'] = isset($forum_life['address']) ? $forum_life['address'] : ''; $forum['url'] = isset($forum_life['url']) ? $forum_life['url'] : ''; $user_fids = array(); if ($this->uid) { $user_fids = Wekit::loadDao('forum.dao.PwForumUserDao')->getFroumByUid($this->uid); } $isjoin = array_key_exists($fid, $user_fids) ? true : false; $count = Wekit::loadDao('forum.dao.PwThreadsDao')->countThreadByFidAndType($fid, 0); $threads = Wekit::loadDao('forum.dao.PwThreadsDao')->getThreadByFid($fid, $this->perpage, $pos); $tids = array_keys($threads); $threads_list = Wekit::load('native.srv.PwDynamicService')->fetchThreadsList($tids, $this->uid); // $result = array('forumInfo'=>$forum,'threadsList'=>$threads_list); // var_dump($result);exit; ($max_page = ceil($count / $this->perpage)) || ($max_page = 1); $page_info = array('page' => $page, 'perpage' => $this->perpage, 'count' => $count, 'max_page' => $max_page); $data = array('page_info' => $page_info, 'user_info' => array('uid' => $this->uid, 'isjoin' => $isjoin), 'forum_info' => $page == 1 ? $forum : '', 'threads_list' => $threads_list); $this->setOutput($data, 'data'); $this->showMessage('NATIVE:data.success'); exit; /* 测试pw提供获取帖子内容service */ $thread_content = Wekit::load('forum.PwThread')->fetchThread(array(26, 45, 43, 44), PwThread::FETCH_ALL); //PW 提供的获取帖子内容方法 var_dump($thread_content); exit; PW::getTime(); //PW工具类 // $thread_content = Wekit::loadDao('forum.dao.PwThreadsContentDao')->getThread(81); // var_dump($thread_content);exit; }