本文整理汇总了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;
}
示例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;
}