當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Pw::formatContent方法代碼示例

本文整理匯總了PHP中Pw::formatContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pw::formatContent方法的具體用法?PHP Pw::formatContent怎麽用?PHP Pw::formatContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pw的用法示例。


在下文中一共展示了Pw::formatContent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: gather

 /**
  * 整理合並貼子內容 
  * 
  * @param mixed $tids 
  * @param mixed $pids 
  * @access public
  * @return void
  */
 public function gather($threadList, $attList)
 {
     if (!is_array($threadList) || !is_array($attList)) {
         return array();
     }
     foreach ($threadList as $key => $thread) {
         $pic_key = $thread['tid'] . '_0';
         $threadList[$key]['pic'] = isset($attList[$pic_key]) ? $attList[$pic_key] : array();
         //列表數據,過濾掉圖片及附件url等標簽
         $_shareData = Pw::formatContent($threadList[$key]['content']);
         $threadList[$key]['share'] = $_shareData['share'];
         $threadList[$key]['content'] = preg_replace('/(\\[)[^\\]]*$/i', '', mb_substr($_shareData['content'], 0, 90));
         //截字並修正表情標簽
         //
         $threadList[$key]['created_user_avatar'] = Pw::getAvatar($threadList[$key]['created_userid'], '');
         //
         $threadList[$key]['lastpost_time'] = Pw::time2str($threadList[$key]['lastpost_time'], 'auto');
     }
     krsort($threadList, SORT_NUMERIC);
     return $threadList;
 }
開發者ID:chendong0444,項目名稱:phpwind,代碼行數:29,代碼來源:PwNativeThread.php

示例2: fetchThreadsList

 /**
  * 獲取列表頁展示的帖子數據
  */
 public function fetchThreadsList($tids, $uid = 0, $result_type = 'ASSOC')
 {
     if (!$tids) {
         return array();
     }
     Wind::import('SRV:like.PwLikeContent');
     $threads = Wekit::loadDao('native.dao.PwNativeThreadsDao')->fetchThreads($tids);
     $threads_place = Wekit::loadDao('native.dao.PwThreadsPlaceDao')->fetchByTids($tids);
     $threads_content = Wekit::loadDao('forum.dao.PwThreadsContentDao')->fetchThread($tids);
     $PwThreadService = Wekit::load('forum.srv.PwThreadService');
     $PwNativeThreadService = Wekit::load('native.PwNativeThread');
     $threadLikeData = Wekit::load('like.srv.reply.do.PwLikeDoReply')->getAllLikeUserids(PwLikeContent::THREAD, $tids);
     foreach ($threadLikeData as $k => $v) {
         if (!in_array($uid, $v)) {
             unset($threadLikeData[$k]);
         }
     }
     $tag_names_str = '';
     foreach ($threads as $k => $v) {
         $content = isset($threads_content[$k]['content']) ? $threads_content[$k]['content'] : '';
         $threads[$k]['tags'] = $threads[$k]['tags_origin'] = isset($threads_content[$k]['tags']) ? $threads_content[$k]['tags'] : '';
         $threads[$k]['from_type'] = isset($threads_place[$k]['from_type']) ? $threads_place[$k]['from_type'] : 0;
         $threads[$k]['created_address'] = isset($threads_place[$k]['created_address']) ? $threads_place[$k]['created_address'] : '';
         $threads[$k]['area_code'] = isset($threads_place[$k]['area_code']) ? $threads_place[$k]['area_code'] : '';
         $threads[$k]['tags'] && ($tag_names_str .= ',' . $threads[$k]['tags']);
         $threads[$k]['avatar'] = Pw::getAvatar($v['created_userid'], 'small');
         $threads[$k]['created_time'] = Pw::time2str($v['created_time'], 'auto');
         $threads[$k]['lastpost_time'] = Pw::time2str($v['lastpost_time'], 'auto');
         preg_match("/\\[mp3.*?\\].*?\\[\\/mp3\\]/i", $content, $matches);
         $threads[$k]['have_mp3'] = $matches ? true : false;
         preg_match("/\\[flash.*?\\].*?\\[\\/flash\\]/i", $content, $matches);
         $threads[$k]['have_flash'] = $matches ? true : false;
         $format_content = Pw::formatContent($content);
         //格式化移動端帖子內容去除ubb標簽、分享鏈接內容、推廣鏈接內容
         $threads[$k]['isliked'] = isset($threadLikeData[$k]) ? true : false;
         $imgs = array_shift($PwNativeThreadService->getThreadAttach(array($k), array(0)));
         ksort($imgs);
         $imgs = array_slice($imgs, 0, 9);
         foreach ($imgs as $imgs_k => $imgs_v) {
             $imgs[$imgs_k]['realpath'] = str_replace("/thumb/mini", "", $imgs_v['path']);
         }
         $threads[$k]['content'] = array('text' => preg_replace('/(\\[)[^\\]]*$/i', '', Pw::substrs($format_content['content'], 70, 0, false)), 'imgs' => $imgs, 'share' => $format_content['share'], 'origin_content' => $content, 'format_content' => $format_content);
     }
     $tag_names_arr = array_unique(explode(',', trim($tag_names_str, ',')));
     $tag_names = Wekit::loadDao('tag.dao.PwTagDao')->getTagsByNames($tag_names_arr);
     //        var_dump($tag_names);exit;
     foreach ($threads as $k => $v) {
         if ($v['tags']) {
             $tag_arr = explode(',', $v['tags']);
             $tag_tmp = array();
             foreach ($tag_arr as $name) {
                 array_key_exists($name, $tag_names) && ($tag_tmp[] = array('tag_id' => $tag_names[$name]['tag_id'], 'tag_name' => $name));
             }
             $threads[$k]['tags'] = $tag_tmp;
         }
     }
     $threads_tmp = array();
     $sort_num = 0;
     if ($result_type == 'ASSOC') {
         //按照tids的順序重新排序結果集,tid作為索引
         foreach ($tids as $v) {
             if (isset($threads[$v])) {
                 $threads_tmp[$v] = $threads[$v];
                 $threads_tmp[$v]['sort'] = $sort_num++;
             }
         }
     } else {
         //tid會有重複的情況,置頂帖在列表中顯示2次,數字順序索引
         foreach ($tids as $v) {
             if (isset($threads[$v])) {
                 $threads[$v]['sort'] = $sort_num++;
                 $threads_tmp[] = $threads[$v];
             }
         }
     }
     //        print_r($threads_tmp);exit;
     return $threads_tmp;
 }
開發者ID:chendong0444,項目名稱:phpwind,代碼行數:81,代碼來源:PwDynamicService.php


注:本文中的Pw::formatContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。