Ejemplo n.º 1
0
 private function _transTopicList($topicList, $type)
 {
     $list = array();
     global $_G;
     $forum = $_G['forum'];
     foreach ($topicList as $topic) {
         $tmpTopicInfo = ForumUtils::getTopicInfo((int) $topic);
         $topicSummary = ForumUtils::getTopicSummary((int) $topic);
         $topicInfo['board_id'] = (int) $tmpTopicInfo['fid'];
         $topicInfo['board_name'] = $fid != 0 ? $forum['name'] : ForumUtils::getForumName($tmpTopicInfo['fid']);
         $topicInfo['board_name'] = WebUtils::emptyHtml($topicInfo['board_name']);
         $topicInfo['topic_id'] = (int) $topic;
         $topicInfo['type_id'] = (int) $tmpTopicInfo['typeid'];
         $topicInfo['sort_id'] = (int) $tmpTopicInfo['sortid'];
         $topicInfo['title'] = WebUtils::emptyHtml($tmpTopicInfo['subject']);
         $topicSummary['msg'] = WebUtils::emptyReturnLine($topicSummary['msg'], ' ');
         $topicInfo['subject'] = $topicSummary['msg'];
         $topicInfo['user_id'] = (int) $tmpTopicInfo['authorid'];
         if ($type = 'favorite' && empty($tmpTopicInfo['author'])) {
             $dateline = UserTopicInfo::getUserfavorite($_G['uid'], $topic);
             $topicInfo['last_reply_date'] = $dateline . '000';
             $topicInfo['user_nick_name'] = UserUtils::getUserName($dateline['uid']);
         } else {
             $topicInfo['last_reply_date'] = $tmpTopicInfo['dateline'] . '000';
             $topicInfo['user_nick_name'] = (string) $tmpTopicInfo['author'];
         }
         $topicInfo['hits'] = (int) $tmpTopicInfo['views'];
         $topicInfo['replies'] = (int) $tmpTopicInfo['replies'];
         $topicInfo['top'] = (int) ForumUtils::isTopTopic($topic) ? 1 : 0;
         $topicInfo['status'] = (int) $tmpTopicInfo['status'];
         $topicInfo['essence'] = (int) $tmpTopicInfo['digest'] ? 1 : 0;
         $topicInfo['hot'] = (int) $tmpTopicInfo['highlight'] ? 1 : 0;
         $topicInfo['pic_path'] = ImageUtils::getThumbImage($topicSummary['image']);
         $list[] = $topicInfo;
     }
     return $list;
 }
Ejemplo n.º 2
0
 /**
  * 获取主题摘要(内容摘要以及图片)
  *
  * @param int $tid 帖子id
  * @param string $type forum为论坛模块,portal为门户模块
  * @param bool $transBr 是否要转换换行
  * @param array $options 参数选项, 可选值: array('imageList' => 1, 'imageListLen' => 9, 'imageListThumb' => 1)
  * @return array array('msg' => '', 'image' => '', 'imageList' => array())
  */
 public static function getTopicSummary($tid, $type = 'forum', $transBr = true, $options = array())
 {
     $summary = array('msg' => '', 'image' => '', 'imageList' => array());
     $summaryLength = WebUtils::getDzPluginAppbymeAppConfig($type == 'forum' ? 'forum_summary_length' : 'portal_summary_length');
     $allowImage = WebUtils::getDzPluginAppbymeAppConfig($type == 'forum' ? 'forum_allow_image' : 'portal_allow_image');
     $allowImage = !($allowImage === '0');
     if ($summaryLength === '0' && !$allowImage) {
         return $summary;
     }
     $content = self::getTopicContent($tid);
     if (!empty($content['main'])) {
         $msg = '';
         $isFindImage = false;
         $isFindImageList = false;
         $getImageList = isset($options['imageList']) ? $options['imageList'] : 0;
         $imageListLen = isset($options['imageListLen']) ? $options['imageListLen'] : 9;
         $imageListThumb = isset($options['imageListThumb']) ? $options['imageListThumb'] : 1;
         $imageListCount = 0;
         foreach ($content['main'] as $line) {
             if ($line['type'] == 'image' && !$isFindImageList) {
                 $imageListCount++;
                 if ($allowImage) {
                     !$isFindImage && ($summary['image'] = $line['content']);
                     if ($getImageList && !$isFindImageList) {
                         $imageListThumb && ($line['content'] = ImageUtils::getThumbImage($line['content']));
                         $summary['imageList'][] = $line['content'];
                     }
                 }
                 $isFindImage = true;
                 !$getImageList && ($isFindImageList = true);
                 $imageListCount == $imageListLen && ($isFindImageList = true);
             }
             if ($line['type'] == 'text') {
                 $msg .= $line['content'] . "\r\n";
             }
         }
         $msg = preg_replace('/\\[mobcent_phiz=.+?\\]/', '', $msg);
         $msg = preg_replace(WebUtils::t('/本帖最后由 .*? 于 .*? 编辑/'), '', $msg);
         $transBr && ($msg = WebUtils::emptyReturnLine($msg, ' '));
         $msg = trim($msg);
         $summaryLength === false && ($summaryLength = 40);
         $summary['msg'] = (string) WebUtils::subString($msg, 0, $summaryLength);
     }
     return $summary;
 }
Ejemplo n.º 3
0
 private function _getInfoList($uid, $puid)
 {
     $list = array();
     $topicList = array();
     if ($uid == $puid) {
         $topicList = DzUserInfo::getFavouriteTopics($uid);
     } else {
         $topicList = DzUserInfo::getTopicsByUid($puid);
     }
     foreach ($topicList as $topic) {
         $topicSummary = ForumUtils::getTopicSummary((int) $topic['tid']);
         $tmpTopic['board_id'] = (int) $topic['fid'];
         $tmpTopic['board_name'] = ForumUtils::getForumName((int) $topic['fid']);
         $tmpTopic['topic_id'] = (int) $topic['tid'];
         $tmpTopic['title'] = $topic['subject'];
         $tmpTopic['user_id'] = (int) $topic['authorid'];
         $tmpTopic['lastpost'] = $topic['lastpost'] . "000";
         $tmpTopic['user_nick_name'] = $topic['author'];
         $tmpTopic['hits'] = (int) $topic['views'];
         $tmpTopic['content'] = WebUtils::emptyReturnLine($topicSummary['msg'], ' ');
         $tmpTopic['replies'] = (int) $topic['replies'];
         $tmpTopic['pic_path'] = ImageUtils::getThumbImage($topicSummary['image']);
         $list[] = $tmpTopic;
     }
     return $list;
 }
Ejemplo n.º 4
0
 private function _filterContent($content)
 {
     $typeMaps = array('text' => 0, 'image' => 1, 'video' => 2, 'audio' => 3, 'url' => 4, 'attachment' => 5);
     $newContent = array();
     foreach ($content as $value) {
         $tempContent['infor'] = $value['content'];
         $tempContent['type'] = $typeMaps[$value['type']];
         switch ($value['type']) {
             case 'image':
                 $tempContent['originalInfo'] = $value['content'];
                 $tempContent['aid'] = isset($value['extraInfo']['aid']) ? $value['extraInfo']['aid'] : 0;
                 $tempContent['infor'] = ImageUtils::getThumbImage($value['content']);
                 break;
             case 'url':
                 $tempContent['infor'] = $value['content'];
                 $tempContent['url'] = $value['extraInfo']['url'];
                 break;
             case 'attachment':
                 $tempContent['infor'] = $value['content'];
                 $tempContent['url'] = $value['extraInfo']['url'];
                 $tempContent['desc'] = $value['extraInfo']['desc'];
                 break;
             case 'video':
                 $videoInfo = ForumUtils::parseVideoUrl($value['content']);
                 $tempContent['extParams'] = array('videoType' => $videoInfo['type'], 'videoId' => $videoInfo['vid']);
                 break;
             default:
                 break;
         }
         // 判定是否开启附件下载
         if (!WebUtils::getDzPluginAppbymeAppConfig('forum_allow_attachment') && $tempContent['type'] == 5) {
             $tempContent = array();
         }
         !empty($tempContent) && ($newContent[] = $tempContent);
     }
     return $newContent;
 }
Ejemplo n.º 5
0
 private function _transMessage($msgString)
 {
     $msg = array('type' => 'text', 'content' => '');
     $matches = array();
     preg_match_all('/<img.*?src="(.*?)".*?\\/>/s', $msgString, $matches, PREG_SET_ORDER);
     if (!empty($matches)) {
         foreach ($matches as $match) {
             $match[1] = WebUtils::getHttpFileName($match[1]);
             if (strpos($match[0], 'static/image/smiley') !== false || strpos($match[0], 'mobcent/app/data/phiz') !== false) {
                 $msgString = str_replace($match[0], sprintf('[mobcent_phiz=%s]', $match[1]), $msgString);
             } else {
                 $msg['type'] = 'image';
                 $msgString = ImageUtils::getThumbImage($match[1]);
                 break;
             }
         }
     }
     $matches = array();
     preg_match_all('/<a href="(.*?)".*?>(.*?)<\\/a>/s', $msgString, $matches, PREG_SET_ORDER);
     if (!empty($matches)) {
         foreach ($matches as $match) {
             $match[1] = WebUtils::getHttpFileName($match[1]);
             if (strpos($match[0], UploadUtils::getUploadAudioBaseUrlPath()) !== false) {
                 $msg['type'] = 'audio';
                 $msgString = $match[1];
                 break;
             } else {
                 // $msgString = str_replace($match[0], sprintf('[mobcent_url=%s]%s[/mobcent_url]', $match[1], $match[2]), $msgString);
                 $msgString = str_replace($match[0], sprintf(' %s %s ', $match[2], $match[1]), $msgString);
             }
         }
     }
     $msg['content'] = WebUtils::emptyHtml($msgString);
     return $msg;
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 private function _getPicByBid($bid)
 {
     global $_G;
     block_get($bid);
     $itemList = $_G['block'][$bid]['itemlist'];
     $list = array();
     foreach ($itemList as $item) {
         $sourceType = $item['idtype'] == 'aid' ? 'news' : 'topic';
         $sourceId = $item['id'];
         $title = $item['title'];
         if ($item['makethumb'] == 1) {
             // 生成缩略图成功
             if ($item['picflag'] == 1) {
                 // 本地
                 $picPath = $_G['setting']['attachurl'] . $item['thumbpath'];
             } elseif ($item['picflag'] == 2) {
                 // 远程
                 $picPath = $_G['setting']['ftp']['attachurl'] . $item['thumbpath'];
             }
         } elseif ($item['makethumb'] == 0) {
             // 缩略图生成失败
             $picPath = $item['pic'];
         }
         $picPath = ImageUtils::getThumbImage(WebUtils::getHttpFileName($picPath));
         $list[] = $this->_fieldPicList(0, $sourceType, $sourceId, $title, $picPath);
     }
     return $list;
 }
Ejemplo n.º 8
0
 private function _fieldInfo($topics)
 {
     $row = $rows = array();
     foreach ($topics as $v) {
         $topicSummary = ForumUtils::getTopicSummary($v['tid']);
         $row['board_id'] = (int) $v['fid'];
         $row['topic_id'] = (int) $v['tid'];
         $row['type_id'] = (int) $v['typeid'];
         $row['sort_id'] = (int) $v['sortid'];
         $row['vote'] = ForumUtils::isVoteTopic($v['tid']) ? 1 : 0;
         $row['title'] = (string) WebUtils::emptyHtml($v['subject']);
         $row['subject'] = (string) WebUtils::emptyReturnLine($topicSummary['msg']);
         $row['user_id'] = (int) $v['authorid'];
         $row['last_reply_date'] = $v['lastpost'] . "000";
         if ($row['last_reply_date'] == '000') {
             $row['last_reply_date'] = $v['dateline'] . "000";
         }
         $row['user_nick_name'] = (string) $v['author'];
         $row['hits'] = (int) $v['views'];
         $row['replies'] = (int) $v['replies'];
         $row['top'] = ForumUtils::isTopTopic($v['tid']) ? 1 : 0;
         $row['status'] = (int) $v['status'];
         $row['essence'] = (int) $v['digest'];
         $row['hot'] = ForumUtils::isHotTopic($v['tid']) ? 1 : 0;
         $row['pic_path'] = ImageUtils::getThumbImage($topicSummary['image']);
         $rows[] = $row;
     }
     return $rows;
 }