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; }
public function run($getSetting, $longitude = 0, $latitude = 0, $location = '') { $res = $this->initWebApiArray(); // $longitude='116.3093650';$latitude='40.0611250';$location='北京市海淀区上地东路'; $location = WebUtils::t(rawurldecode($location)); global $_G; ($uid = $_G['uid']) && $this->_saveUserLocation($uid, $longitude, $latitude, $location); // $getSetting ="{'body': {'postInfo': {'forumIds': '0'}}}"; $settings = rawurldecode($getSetting); $settings = WebUtils::jsonDecode($settings); $postInfo = isset($settings['body']['postInfo']) ? $settings['body']['postInfo'] : array(); if (!empty($postInfo)) { $res['body']['postInfo'] = $this->_getPostInfo($postInfo); } $res['body']['serverTime'] = time() . '000'; $res['body']['misc'] = $this->_getMiscSetting(); $res['body']['plugin'] = $this->_getPluginSetting(); $res['body']['forum'] = $this->_getForumSetting(); $res['body']['portal'] = $this->_getPortalSetting(); $res['body']['user'] = $this->_getUserSetting(); $res['body']['message'] = $this->_getMessageSetting(); $res['body']['moduleList'] = PortalUtils::getModuleList(6); // 2014/11/4 门户资讯分类模块列表 echo WebUtils::outputWebApi($res, '', false); }
private function _getNewsInfo($article, $page) { global $_G; $newsInfo = array(); $aid = $article['aid']; $articleUrl = $this->_fetchArticleUrl($aid); // 门户静态化,暂时去掉这个跳转,因为有些用户不支持wap版的门户页面 /* if(!empty($_G['setting']['makehtml']['flag']) && $article['htmlmade'] && !isset($_G['makehtml']) && empty($_GET['diy']) && empty($article['url'])) { // dheader('location:'. fetch_article_url($article)); $newsInfo['redirectUrl'] = $articleUrl; return $newsInfo; } */ $article_count = C::t('portal_article_count')->fetch($aid); if ($article_count) { $article = array_merge($article_count, $article); } if ($article_count) { C::t('portal_article_count')->increase($aid, array('viewnum' => 1)); unset($article_count); } else { C::t('portal_article_count')->insert(array('aid' => $aid, 'catid' => $article['catid'], 'viewnum' => 1)); } if ($article['url']) { // if(!isset($_G['makehtml'])) { // dheader("location:{$article['url']}"); // } // exit(); $newsInfo['redirectUrl'] = $article['url']; return $newsInfo; } $cat = category_remake($article['catid']); $article['pic'] = pic_get($article['pic'], '', $article['thumb'], $article['remote'], 1, 1); if ($page < 1) { $page = 1; } $org = array(); if ($article['idtype'] == 'blogid') { $org = C::t('home_blog')->fetch($article['id']); if (empty($org)) { C::t('portal_article_title')->update($aid, array('id' => 0, 'idtype' => '')); // dheader('location: '. fetch_article_url($article)); // exit(); $newsInfo['redirectUrl'] = $articleUrl; return $newsInfo; } } $article['allowcomment'] = !empty($cat['allowcomment']) && !empty($article['allowcomment']) ? 1 : 0; $article['timestamp'] = $article['dateline']; $article['dateline'] = dgmdate($article['dateline']); $newsInfo['redirectUrl'] = ''; $newsInfo['catName'] = WebUtils::t('文章详情'); $newsInfo['title'] = WebUtils::emptyHtml($article['title']); $newsInfo['dateline'] = $article['dateline']; $newsInfo['author'] = $article['username']; $newsInfo['viewNum'] = (int) $article['viewnum']; $newsInfo['commentNum'] = (int) $article['commentnum']; $newsInfo['allowComment'] = $article['allowcomment'] ? 1 : 0; $newsInfo['summary'] = $article['summary']; $newsInfo['pageCount'] = (int) $article['contents']; $newsInfo['from'] = $article['from']; $newsInfo['articleUrl'] = $articleUrl; $newsInfo['content'] = $this->_transContent(PortalUtils::getNewsContent($article, $page)); return $newsInfo; }
public function actionArticleInfo($aid) { $article = PortalUtils::getNewsInfo($aid); echo WebUtils::jsonEncode($article); }
public static function transArticleContent($content) { $content = PortalUtils::parseArticleContent($content); $newContent = array(); $matches = array(); preg_match_all('/(.+?)\\[mobcent_br\\]/s', $content, $matches); foreach ($matches[1] as $match) { $tempMatches = array(); $tempContent = array('type' => 'text', 'content' => ''); preg_match('/\\[mobcent_(audio|video|image)=(.*?)\\]/', $match, $tempMatches); if (!empty($tempMatches)) { $tempContent['type'] = $tempMatches[1]; $tempContent['content'] = $tempMatches[2]; if ($tempContent['type'] == 'image') { $tempContent['extraInfo']['source'] = $tempMatches[2]; $tempContent['content'] = ImageUtils::getThumbImage($tempMatches[2]); } } else { $match = preg_replace('/(<p>|<\\/p>|<div>|<\\/div>|<br>|<br\\/>)/i', PortalUtils::CONTENT_DELIMITER, $match); $match .= PortalUtils::CONTENT_DELIMITER; $tempText = ''; $tempMatches = array(); preg_match_all('/(.+?)\\[mobcent_br\\]/s', $match, $tempMatches); foreach ($tempMatches[1] as $value) { $value = str_replace(PortalUtils::CONTENT_DELIMITER, '', $value); $tempText .= $value . "\r\n"; } $tempText = WebUtils::emptyHtml($tempText); $tempText = (string) trim($tempText); $tempContent['content'] = $tempText; } $tempContent['content'] != '' && ($newContent[] = $tempContent); } return $newContent; }
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; }
private function _getModuleList() { // 封装:PortalUtils.php,6:截取的数组长度 Date:2014/11/4 return PortalUtils::getModuleList(6); }