private function _getShareData($shareInfo) { $data = array('title' => '', 'source' => '', 'content' => array()); $shareInfo = !empty($shareInfo['body']['shareInfo']) ? $shareInfo['body']['shareInfo'] : array(); if (!empty($shareInfo)) { $sid = $shareInfo['shareId']; $type = $shareInfo['shareType']; switch ($type) { case 'topic': $info = ForumUtils::getTopicInfo($sid); $content = ForumUtils::getTopicContent($sid); $data['title'] = !empty($info['subject']) ? $info['subject'] : ''; $data['source'] = !empty($info['dateline']) ? date('Y-m-d H:i:s', $info['dateline']) : ''; $data['content'] = $this->_getPostContent($content); break; case 'news': $info = PortalUtils::getNewsInfo($sid); $content = PortalUtils::getNewsContent($info); $data['title'] = !empty($info['title']) ? $info['title'] : ''; $data['source'] = !empty($info['dateline']) ? date('Y-m-d H:i:s', $info['dateline']) : ''; $data['content'] = $this->_filterContent($content); break; default: break; } } return $data; }
/** * 获取文章内容 * * @param int|array $aid * @param int $page * @return array */ public static function getNewsContent($aid, $page = 1) { global $_G; $article = $aid; !is_array($aid) && ($article = PortalUtils::getNewsInfo($aid)); $content = C::t('portal_article_content')->fetch_by_aid_page($article['aid'], $page); if (empty($content)) { return $content; } $content['content'] = PortalUtils::preParseArticleContent($content['content']); require_once libfile('function/blog'); $content['content'] = blog_bbcode($content['content']); if ($article['idtype'] == 'tid' || $content['idtype'] == 'pid') { $thread = $firstpost = array(); require_once libfile('function/discuzcode'); require_once libfile('function/forum'); $thread = get_thread_by_tid($article['id']); if (!empty($thread)) { if ($content['idtype'] == 'pid') { $firstpost = C::t('forum_post')->fetch($thread['posttableid'], $content['id']); } else { $firstpost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($article['id']); } if ($firstpost && $firstpost['tid'] == $article['id']) { $firstpost['uid'] = $firstpost['authorid']; $firstpost['username'] = $firstpost['author']; } } if (!empty($firstpost) && !empty($thread) && $thread['displayorder'] != -1) { $_G['tid'] = $article['id']; $aids = array(); $firstpost['message'] = $content['content']; if ($thread['attachment']) { $_G['group']['allowgetimage'] = 1; if (preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $firstpost['message'], $matchaids)) { $aids = $matchaids[1]; } } if ($aids) { parseforumattach($firstpost, $aids); } $content['content'] = $firstpost['message']; $content['pid'] = $firstpost['pid']; } else { C::t('portal_article_title')->update($aid, array('id' => 0, 'idtype' => '')); C::t('portal_article_content')->update_by_aid($aid, array('id' => 0, 'idtype' => '')); } } elseif ($article['idtype'] == 'blogid') { $content['content'] = ''; } return PortalUtils::transArticleContent($content['content']); }
public function actionArticleInfo($aid) { $article = PortalUtils::getNewsInfo($aid); echo WebUtils::jsonEncode($article); }
private function _getArticleByAid($aid) { $articleCount = PortalUtils::getArticleCount($aid); $articleInfo = PortalUtils::getNewsInfo($aid); // [add]考虑文章是通过帖子来发布的时候的评论数问题 Author:HanPengyu,Data:14.09.27 if ($articleInfo['idtype'] == 'tid') { $topicInfo = ForumUtils::getTopicInfo($articleInfo['id']); $articleCount['commentnum'] = (int) $topicInfo['replies']; } $articleInfo = array_merge($articleCount, $articleInfo); return $articleInfo; }