Exemplo n.º 1
0
 /**
  * 帖子阅读页
  */
 public function run()
 {
     $tid = intval($this->getInput('tid'));
     list($page, $uid, $desc) = $this->getInput(array('page', 'uid', 'desc'), 'get');
     $threadDisplay = new PwThreadDisplay($tid, $this->loginUser);
     $this->runHook('c_read_run', $threadDisplay);
     if (($result = $threadDisplay->check()) !== true) {
         $this->showError($result->getError());
     }
     $_cache = Wekit::cache()->fetch(array('level', 'group_right'));
     $pwforum = $threadDisplay->getForum();
     if ($pwforum->foruminfo['password']) {
         if (!$this->loginUser->isExists()) {
             $this->forwardAction('u/login/run', array('backurl' => WindUrlHelper::createUrl('bbs/cate/run', array('fid' => ${$pwforum}->fid))));
         } elseif (Pw::getPwdCode($pwforum->foruminfo['password']) != Pw::getCookie('fp_' . $pwforum->fid)) {
             $this->forwardAction('bbs/forum/password', array('fid' => $pwforum->fid));
         }
     }
     if ($uid) {
         Wind::import('SRV:forum.srv.threadDisplay.PwUserRead');
         $dataSource = new PwUserRead($threadDisplay->thread, $uid);
     } else {
         Wind::import('SRV:forum.srv.threadDisplay.PwCommonRead');
         $dataSource = new PwCommonRead($threadDisplay->thread);
     }
     $dataSource->setPage($page)->setPerpage($pwforum->forumset['readperpage'] ? $pwforum->forumset['readperpage'] : Wekit::C('bbs', 'read.perpage'))->setDesc($desc);
     $threadDisplay->setImgLazy(Wekit::C('bbs', 'read.image_lazy'));
     $threadDisplay->execute($dataSource);
     $operateReply = $operateThread = array();
     $isBM = $pwforum->isBM($this->loginUser->username);
     if ($threadPermission = $this->loginUser->getPermission('operate_thread', $isBM, array())) {
         $operateReply = Pw::subArray($threadPermission, array('toppedreply', 'remind', 'shield', 'delete', 'ban', 'inspect', 'read'));
         $operateThread = Pw::subArray($threadPermission, array('digest', 'topped', 'up', 'highlight', 'copy', 'type', 'move', 'lock', 'down', 'delete', 'ban'));
     }
     $threadInfo = $threadDisplay->getThreadInfo();
     $this->setOutput($threadDisplay, 'threadDisplay');
     $this->setOutput($tid, 'tid');
     $this->setOutput($threadDisplay->fid, 'fid');
     $this->setOutput($threadInfo, 'threadInfo');
     $this->setOutput($threadDisplay->getList(), 'readdb');
     $this->setOutput($threadDisplay->getUsers(), 'users');
     $this->setOutput($pwforum, 'pwforum');
     $this->setOutput(PwCreditBo::getInstance(), 'creditBo');
     $this->setOutput($threadDisplay->getHeadguide(), 'headguide');
     $this->setOutput(Wekit::C('bbs', 'read.display_member_info'), 'displayMemberInfo');
     $this->setOutput(Wekit::C('bbs', 'read.display_info'), 'displayInfo');
     $this->setOutput(Wekit::C('bbs', 'thread.hotthread_replies'), 'hotIcon');
     $this->setOutput($threadPermission, 'threadPermission');
     $this->setOutput($operateThread, 'operateThread');
     $this->setOutput($operateReply, 'operateReply');
     $this->setOutput(!$this->loginUser->uid && !$this->allowPost($pwforum) ? ' J_qlogin_trigger' : '', 'postNeedLogin');
     $this->setOutput(!$this->loginUser->uid && !$this->allowReply($pwforum) ? ' J_qlogin_trigger' : '', 'replyNeedLogin');
     $this->setOutput($_cache['level']['ltitle'], 'ltitle');
     $this->setOutput($_cache['level']['lpic'], 'lpic');
     $this->setOutput($_cache['level']['lneed'], 'lneed');
     $this->setOutput($_cache['group_right'], 'groupRight');
     $this->setOutput($threadDisplay->page, 'page');
     $this->setOutput($threadDisplay->perpage, 'perpage');
     $this->setOutput($threadDisplay->total, 'count');
     $this->setOutput($threadDisplay->maxpage, 'totalpage');
     $this->setOutput($threadDisplay->getUrlArgs(), 'urlargs');
     $this->setOutput($threadDisplay->getUrlArgs('desc'), 'urlDescArgs');
     $this->setOutput($this->loginUser->getPermission('look_thread_log', $isBM, array()), 'canLook');
     $this->setOutput($this->_getFpage($threadDisplay->fid), 'fpage');
     //版块风格
     if ($pwforum->foruminfo['style']) {
         $this->setTheme('forum', $pwforum->foruminfo['style']);
         //$this->addCompileDir($pwforum->foruminfo['style']);
     }
     // seo设置
     Wind::import('SRV:seo.bo.PwSeoBo');
     $seoBo = PwSeoBo::getInstance();
     $lang = Wind::getComponent('i18n');
     $threadDisplay->page <= 1 && $seoBo->setDefaultSeo($lang->getMessage('SEO:bbs.read.run.title'), '', $lang->getMessage('SEO:bbs.read.run.description'));
     $seoBo->init('bbs', 'read');
     $seoBo->set(array('{forumname}' => $threadDisplay->forum->foruminfo['name'], '{title}' => $threadDisplay->thread->info['subject'], '{description}' => Pw::substrs($threadDisplay->thread->info['content'], 100, 0, false), '{classfication}' => $threadDisplay->thread->info['topic_type'], '{tags}' => $threadInfo['tags'], '{page}' => $threadDisplay->page));
     Wekit::setV('seo', $seoBo);
     //是否显示回复
     $showReply = true;
     //锁定时间
     if ($pwforum->forumset['locktime'] && $threadInfo['created_time'] + $pwforum->forumset['locktime'] * 86400 < Pw::getTime()) {
         $showReply = false;
     } elseif (Pw::getstatus($threadInfo['tpcstatus'], PwThread::STATUS_LOCKED) && !$this->loginUser->getPermission('reply_locked_threads')) {
         $showReply = false;
     }
     $this->setOutput($showReply, 'showReply');
     $this->runReadDesign($threadDisplay->fid);
     $this->updateReadOnline($threadDisplay->fid, $tid);
 }
Exemplo n.º 2
0
 /**
  * 分享到其它平台使用的链接 
  * 
  * @access public
  * @return void
  * @example
  * <pre>
  * /index.php?m=native&c=read&a=sharePage&tid=21
  * </pre>
  */
 public function sharePageAction()
 {
     $tid = intval($this->getInput('tid', 'get'));
     list($page, $uid, $desc) = $this->getInput(array('page', 'uid', 'desc'), 'get');
     $threadDisplay = new PwThreadDisplay($tid, $this->loginUser);
     $this->runHook('c_read_run', $threadDisplay);
     if (($result = $threadDisplay->check()) !== true) {
         $this->showError($result->getError());
     }
     $_cache = Wekit::cache()->fetch(array('level', 'group_right'));
     $pwforum = $threadDisplay->getForum();
     if ($pwforum->foruminfo['password']) {
         if (!$this->uid) {
             $this->forwardAction('u/login/run', array('backurl' => WindUrlHelper::createUrl('bbs/cate/run', array('fid' => ${$pwforum}->fid))));
         } elseif (Pw::getPwdCode($pwforum->foruminfo['password']) != Pw::getCookie('fp_' . $pwforum->fid)) {
             $this->forwardAction('bbs/forum/password', array('fid' => $pwforum->fid));
         }
     }
     Wind::import('SRV:forum.srv.threadDisplay.PwCommonRead');
     $dataSource = new PwCommonRead($threadDisplay->thread);
     //数据分页
     $perpage = $pwforum->forumset['readperpage'] ? $pwforum->forumset['readperpage'] : Wekit::C('bbs', 'read.perpage');
     $dataSource->setPage($page)->setPerpage($perpage)->setDesc($desc);
     $threadDisplay->setImgLazy(Wekit::C('bbs', 'read.image_lazy'));
     $threadDisplay->execute($dataSource);
     //主题的信息
     $threadInfo = $threadDisplay->getThreadInfo();
     $threadInfo['content'] = preg_replace('/onload="([^"]+)"/i', '', $threadInfo['content']);
     $threadInfo['content'] = preg_replace('/onclick="([^"]+)"/i', '', $threadInfo['content']);
     $threadInfo['content'] = str_replace('style="max-width:700px;"', '', $threadInfo['content']);
     preg_match_all('/<div class="J_video" data-url="(.+?\\.swf.*?)".*?><\\/div>/i', $threadInfo['content'], $matches);
     if (isset($matches[0]) && $matches[0]) {
         $count = count($matches[0]);
         for ($i = 0; $i < $count; $i++) {
             $vedio = '<embed src="' . $matches[1][$i] . '" allowFullScreen="true" quality="high" width="240" height="200" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed><br>';
             //                echo $vedio."<br>";
             $threadInfo['content'] = str_replace($matches[0][$i], $vedio, $threadInfo['content']);
         }
     }
     //帖子内容音频资源
     preg_match_all('/<div class="J_audio".*?data-url="(.+?)".*?><\\/div>/i', $threadInfo['content'], $matches);
     if (isset($matches[0]) && $matches[0]) {
         $count = count($matches[0]);
         for ($i = 0; $i < $count; $i++) {
             $audio = '<br><audio controls="controls" src="' . $matches[1][$i] . '">不支持音乐</audio><br>';
             $threadInfo['content'] = str_replace($matches[0][$i], $audio, $threadInfo['content']);
         }
     }
     //帖子数据列表
     $threadList = $threadDisplay->getList();
     $threadList = array_slice($threadList, 1, 3);
     foreach ($threadList as $k => $v) {
         preg_match_all('/<div class="J_video" data-url="(.+?\\.swf.*?)".*?><\\/div>/i', $v['content'], $matches);
         if (isset($matches[0]) && $matches[0]) {
             $count = count($matches[0]);
             for ($i = 0; $i < $count; $i++) {
                 $vedio = '<embed src="' . $matches[1][$i] . '" allowFullScreen="true" quality="high" width="240" height="200" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed><br>';
                 //                echo $vedio."<br>";
                 $threadList[$k]['content'] = str_replace($matches[0][$i], $vedio, $v['content']);
             }
         }
         preg_match_all('/<div class="J_audio".*?data-url="(.+?)".*?><\\/div>/i', $v['content'], $matches);
         if (isset($matches[0]) && $matches[0]) {
             $count = count($matches[0]);
             for ($i = 0; $i < $count; $i++) {
                 $audio = '<br><audio controls="controls" src="' . $matches[1][$i] . '">不支持音乐</audio><br>';
                 $threadList[$k]['content'] = str_replace($matches[0][$i], $audio, $v['content']);
             }
         }
     }
     //var_dump($threadList);exit;
     $this->setOutput(Wekit::getGlobal('url', 'res'), 'resPath');
     $this->setOutput($threadInfo, 'threadInfo');
     $this->setOutput($threadList, 'threadList');
     $this->setOutput($threadDisplay, 'threadDisplay');
     $this->setOutput(PwCreditBo::getInstance(), 'creditBo');
 }
Exemplo n.º 3
0
 /**
  * 无图版帖子阅读页
  */
 public function readAction()
 {
     list($tid, $page) = $this->getInput(array('tid', 'page'), 'GET');
     /* @var $threadDisplay PwThreadDisplay */
     Wind::import('SRV:forum.srv.PwThreadDisplay');
     $threadDisplay = new PwThreadDisplay($tid, $this->loginUser);
     if (($result = $threadDisplay->check()) !== true) {
         $this->showMessage($result->getError());
     }
     $pwforum = $threadDisplay->getForum();
     $this->_checkForumRight($pwforum);
     /* @var $dataSource PwCommonRead */
     Wind::import('SRV:forum.srv.threadDisplay.PwCommonRead');
     $dataSource = new PwCommonRead($threadDisplay->thread);
     $dataSource->setPage($page);
     $dataSource->setPerpage(25);
     $threadDisplay->execute($dataSource);
     Wind::import('SRV:seo.bo.PwSeoBo');
     $seoBo = PwSeoBo::getInstance();
     $lang = Wind::getComponent('i18n');
     $threadDisplay->page <= 1 && $seoBo->setDefaultSeo($lang->getMessage('SEO:bbs.read.run.title'), '', $lang->getMessage('SEO:bbs.read.run.description'));
     $seoBo->init('bbs', 'read');
     $seoBo->set(array('{forumname}' => $threadDisplay->forum->foruminfo['name'], '{title}' => $threadDisplay->thread->info['subject'], '{description}' => Pw::substrs($threadDisplay->thread->info['content'], 100, 0, false), '{classfication}' => $threadDisplay->thread->info['topic_type'], '{tags}' => $threadDisplay->thread->info['tags'], '{page}' => $threadDisplay->page));
     Wekit::setV('seo', $seoBo);
     $this->setOutput($tid, 'tid');
     $this->setOutput($threadDisplay->fid, 'fid');
     $this->setOutput($threadDisplay->getThreadInfo(), 'threadInfo');
     $this->setOutput($threadDisplay->getList(), 'readdb');
     $this->setOutput($pwforum, 'pwforum');
     $this->setOutput($threadDisplay->page, 'page');
     $this->setOutput($threadDisplay->perpage, 'perpage');
     $this->setOutput($threadDisplay->total, 'count');
     $this->setOutput($threadDisplay->maxpage, 'totalpage');
     $this->setTemplate('simple_read');
 }