Beispiel #1
0
 /**
  * 获取文章摘要(内容摘要以及图片)
  *
  * @param int $aid 文章id
  * @param bool $transBr 是否要转换换行
  * @param array $options 参数选项, 可选值: array('imageList' => 1, 'imageListLen' => 9, 'imageListThumb' => 1)
  * @return array array('msg' => '', 'image' => '', 'imageList' => array())
  */
 public static function getArticleSummary($aid, $transBr = true, $options = array())
 {
     $summary = array('msg' => '', 'image' => '', 'imageList' => array());
     $summaryLength = WebUtils::getDzPluginAppbymeAppConfig('portal_summary_length');
     $allowImage = WebUtils::getDzPluginAppbymeAppConfig('portal_allow_image');
     $allowImage = !($allowImage === '0');
     if ($summaryLength === '0' && !$allowImage) {
         return $summary;
     }
     require_once DISCUZ_ROOT . './source/function/function_home.php';
     $article = DzPortalArticle::getArticleByAid($aid);
     if (!empty($article)) {
         $getImageList = isset($options['imageList']) ? $options['imageList'] : 0;
         $imageListLen = isset($options['imageListLen']) ? $options['imageListLen'] : 9;
         $imageListThumb = isset($options['imageListThumb']) ? $options['imageListThumb'] : 1;
         $msg = $article['summary'];
         if ($article['pic']) {
             // $article['pic'] = pic_get($article['pic'], '', $article['thumb'], $article['remote'], 1, 1);
             $article['pic'] = pic_get($article['pic'], '', $article['thumb'], $article['remote'], 0, 1);
             if ($allowImage) {
                 $summary['image'] = WebUtils::getHttpFileName($article['pic']);
                 if ($getImageList) {
                     $tempImage = $summary['image'];
                     $imageListThumb && ($tempImage = ImageUtils::getThumbImage($tempImage));
                     $summary['imageList'][] = $tempImage;
                 }
             }
         }
         $transBr && ($msg = WebUtils::emptyReturnLine($msg, ' '));
         $msg = trim($msg);
         $summaryLength === false && ($summaryLength = 40);
         $summary['msg'] = (string) WebUtils::subString($msg, 0, $summaryLength);
     }
     return $summary;
 }
Beispiel #2
0
 public static function getAttachUrl($remote = false)
 {
     global $_G;
     $setting = $_G['setting'];
     $attachUrl = WebUtils::getHttpFileName($setting['attachurl']);
     $remote && $_G['setting']['ftp']['on'] == 1 && ($attachUrl = WebUtils::getHttpFileName($setting['ftp']['attachurl']));
     return $attachUrl;
 }
 public static function getActivityInfo($tid)
 {
     $activity = array('image' => '', 'summary' => '', 'content' => array(), 'action' => array(), 'applyList' => array());
     $activityInfo = ForumUtils::getTopicActivityInfo($tid);
     if (!empty($activityInfo)) {
         $activity['image'] = WebUtils::getHttpFileName($activityInfo['thumb']);
         $activity['summary'] = self::_getActivitySummary($activityInfo);
         $activity['action'] = self::_getActivityAction($activityInfo);
         $activity['applyList'] = self::_getActivityApplyList($activityInfo);
         $activity['applyListVerified'] = self::_getActivityApplyListVerified($activityInfo);
     }
     return $activity;
 }
Beispiel #4
0
 private function _fetchArticleUrl($aid)
 {
     return WebUtils::getHttpFileName('portal.php?mod=view&aid=' . $aid);
 }
 /**
  * 获得在pc访问的url
  * 
  * @param mixed  $souceId 源的ID
  * @param string $sourceType 源的类型(topic|news)
  *
  * @return string 访问地址
  */
 public static function getSourceWebUrl($souceId, $sourceType = 'topic')
 {
     $sourceWebUrl = '';
     switch ($sourceType) {
         case 'topic':
             $sourceWebUrl = WebUtils::getHttpFileName('forum.php?mod=viewthread&tid=' . $souceId);
             break;
         case 'news':
             $sourceWebUrl = WebUtils::getHttpFileName('portal.php?mod=view&aid=' . $souceId);
             break;
         default:
             break;
     }
     return $sourceWebUrl;
 }
 private function _getPostInfos($res, $topic, $page, $pageSize, $order, $authorId, $params = array())
 {
     extract($params);
     $postInfos = array();
     $tid = (int) $topic['tid'];
     $postCount = ForumUtils::getPostCount($tid, array('authorId' => $authorId));
     if (!empty($topic)) {
         global $_G;
         $isOnlyAuthorTopic = ForumUtils::isOnlyAuthorTopic($topic);
         $postList = ForumUtils::getPostList($tid, $page, $pageSize, array('order' => $order ? 'dateline DESC' : 'dateline ASC', 'authorId' => $authorId));
         $position = $order ? $postCount + 1 - $pageSize * ($page - 1) : $pageSize * ($page - 1) + 2;
         if (MobcentDiscuz::getMobcentDiscuzVersion() > 'x25' && $_G['setting']['repliesrank'] && $postList) {
             if ($postList) {
                 $tempPids = array();
                 $tempPostRecommends = array();
                 foreach ($postList as $post) {
                     $tempPids[] = (int) $post['pid'];
                 }
                 foreach (C::t('forum_hotreply_number')->fetch_all_by_pids(array_values($tempPids)) as $pid => $post) {
                     $tempPostRecommends[$pid]['support'] = dintval($post['support']);
                     // $tempPostRecommends[$pid]['against'] = dintval($post['against']);
                 }
                 $isSupport = DzSupportInfo::getSupportPostsByUidAndTid($_G['uid'], $tid);
             }
         }
         foreach ($postList as $post) {
             $pid = (int) $post['pid'];
             $content = ForumUtils::getPostContent($tid, $pid, $post);
             $isOnlyAuthorPost = $isOnlyAuthorTopic && $_G['uid'] != $post['authorid'] && $_G['uid'] != $_G['forum_thread']['authorid'] && !$post['first'] && !$_G['forum']['ismoderator'];
             $postInfo['reply_id'] = ForumUtils::isAnonymousPost($tid, $post) ? 0 : (int) $post['authorid'];
             $postInfo['reply_content'] = $isOnlyAuthorPost ? $this->_filterContent(array(array('content' => WebUtils::t('此帖仅作者可见'), 'type' => 'text'))) : $this->_getPostContent($content);
             $postInfo['reply_type'] = 'normal';
             $this->_isComplexContent($postInfo['reply_content']) && ($postInfo['reply_type'] = 'normal_complex');
             $postInfo['reply_name'] = ForumUtils::isAnonymousPost($tid, $post) ? $this->_getAnonymoustext() : $post['author'];
             $postInfo['reply_posts_id'] = $pid;
             // 抢楼帖时采用原楼层
             if (getstatus($topic['status'], 3)) {
                 $postInfo['position'] = $post['position'];
             } else {
                 $postInfo['position'] = $order ? $position-- : $position++;
             }
             $postInfo['posts_date'] = $post['dateline'] . '000';
             $postInfo['icon'] = UserUtils::getUserAvatar($postInfo['reply_id']);
             $postInfo['level'] = $this->_getUserLevel($postInfo['reply_id']);
             $postInfo['userTitle'] = UserUtils::getUserTitle($postInfo['reply_id']);
             $postInfo['location'] = ForumUtils::getPostLocation($pid);
             $postInfo['mobileSign'] = ForumUtils::getMobileSign($post['status']);
             // if(empty($post['author']) && isset($post['authorid']) && !empty($post['authorid'])){
             //     $postInfo['reply_status'] = -1;
             // }elseif(empty($post ['author']) && empty($post ['authorid'])){
             //     $postInfo['reply_status'] = 0;
             // }else{
             //     $postInfo['reply_status'] = 1;
             // }
             $postInfo['reply_status'] = 1;
             $postInfo['status'] = 1;
             $postInfo['role_num'] = 1;
             $postInfo['title'] = '';
             $postInfo = array_merge($postInfo, $this->_getPostQuoteInfo($content, $isOnlyAuthorPost));
             // 回帖管理面板编辑 start
             $userMember = $this->_getUserInfoByAuthorid($post['authorid']);
             $userMember = array_merge($userMember, $post);
             $params = array('editPerm' => $editPerm, 'userMember' => $userMember);
             // end
             $manageItems = ForumUtils::getPostManagePanel($params);
             foreach ($manageItems['post'] as $key => $item) {
                 if ($item['action'] == 'edit') {
                     $item['action'] = WebUtils::getHttpFileName("forum.php?mod=post&action=edit&fid={$post['fid']}&tid={$post['tid']}&pid={$post['pid']}");
                 } else {
                     $item['action'] = WebUtils::createUrl_oldVersion('forum/topicadminview', array('fid' => $post['fid'], 'tid' => $tid, 'pid' => $post['pid'], 'act' => $item['action'], 'type' => 'post'));
                 }
                 $manageItems['post'][$key] = $item;
             }
             $count = mb_strlen($postInfo['reply_content'][0]['infor'], $_G['charset']);
             if ($count < $_G['setting']['threadfilternum']) {
                 $isWater = true;
             }
             $isWater = false;
             $count = mb_strlen($postInfo['reply_content'][0]['infor'], $_G['charset']);
             if ($_G['setting']['filterednovote'] && $count < $_G['setting']['threadfilternum']) {
                 $isWater = true;
             }
             $extraItems = array();
             $tempExtraItems = ForumUtils::getPostExtraPanel();
             foreach ($tempExtraItems['post'] as $key => $item) {
                 $item['extParams'] = array('beforeAction' => '');
                 $item['type'] = $item['action'];
                 $item['action'] = '';
                 if ($item['type'] == 'support' && !$isWater) {
                     $item['action'] = WebUtils::createUrl_oldVersion('forum/support', array('tid' => $tid, 'pid' => $post['pid'], 'type' => 'post'));
                     $item['extParams']['recommendAdd'] = (int) $tempPostRecommends[$post['pid']]['support'];
                     $isRecommendAdd = in_array($post['pid'], $isSupport) ? 1 : 0;
                     $item['extParams']['isHasRecommendAdd'] = (int) $isRecommendAdd;
                 }
                 if ($item['type'] != 'support' || !$isWater) {
                     $extraItems[] = $item;
                 }
             }
             $postInfo['managePanel'] = $manageItems['post'];
             $postInfo['extraPanel'] = $extraItems;
             $postInfos[] = $postInfo;
         }
     }
     $res = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $postCount, $res);
     $res['list'] = $postInfos;
     return $res;
 }
 public static function getPhotosoRiginCover($albumImage)
 {
     require_once DISCUZ_ROOT . './source/function/function_home.php';
     $image = pic_get($albumImage['filepath'], 'album', 0, $albumImage['remote']);
     return WebUtils::getHttpFileName($image);
 }
Beispiel #8
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;
 }
Beispiel #9
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;
 }
 private function _getForumInfo($fid)
 {
     global $_G;
     $forum = $_G['forum'];
     require_once libfile('function/forumlist');
     $forumImage = get_forumimg($forum['icon']);
     $forumImage = (string) WebUtils::getHttpFileName($forumImage);
     $forumInfo = array();
     $forumInfo['id'] = (int) $fid;
     $forumInfo['title'] = $fid != 0 ? (string) WebUtils::emptyHtml($forum['name']) : '';
     $forumInfo['description'] = (string) WebUtils::emptyHtml($forum['description']);
     $forumInfo['icon'] = (string) $forumImage;
     return $forumInfo;
 }
 private function _getForumInfo($forum)
 {
     $fid = (int) $forum['fid'];
     $forum = array_merge($forum, DzForumForum::getForumFieldByFid($fid));
     $dateline = $this->_getDateLine($forum);
     // 判断该版块是否有权限访问
     if (!forum($forum)) {
         return array();
     }
     $matches = array();
     preg_match('/<img src="(.+?)"/', $forum['icon'], $matches);
     $image = !empty($matches[1]) ? $matches[1] : '';
     // $dateline = '0';
     // if (is_array($forum['lastpost'])) {
     //     $matches = array();
     //     preg_match('/<span title="(.+?)"/', $forum['lastpost']['dateline'], $matches);
     //     $dateline = !empty($matches[1]) ? $matches[1] : $forum['lastpost']['dateline'];
     //     $dateline = strtotime($dateline);
     //     $dateline !== false or $dateline = '0';
     // }
     $forumSubList = ForumUtils::getForumSubList($fid);
     $forumInfo = array();
     $forumInfo['board_id'] = (int) $fid;
     $forumInfo['board_name'] = WebUtils::emptyHtml($forum['name']);
     $forumInfo['description'] = (string) WebUtils::emptyHtml($forum['description']);
     $forumInfo['board_child'] = count($forumSubList) > 0 ? 1 : 0;
     $forumInfo['board_img'] = WebUtils::getHttpFileName($image);
     $forumInfo['last_posts_date'] = !empty($dateline) ? $dateline . '000' : '';
     $forumInfo['board_content'] = $forum['threads'] != 0 && !($forum['simple'] & 1) ? 1 : 0;
     $forumInfo['forumRedirect'] = $forum['redirect'];
     $todayPosts = (int) $forum['todayposts'];
     $threads = (int) $forum['threads'];
     $posts = (int) $forum['posts'];
     foreach ($forumSubList as $value) {
         $todayPosts += $value['todayposts'];
         $threads += $value['threads'];
         $posts += $value['posts'];
     }
     $forumInfo['td_posts_num'] = $todayPosts;
     $forumInfo['topic_total_num'] = $threads;
     $forumInfo['posts_total_num'] = $posts;
     return $forumInfo;
 }
Beispiel #12
0
 public static function getPhotoAlbumCover($image)
 {
     return WebUtils::getHttpFileName($image);
 }