private function _getWeibaInfo(&$post_list) { //读取微吧详细信息 $weiba_ids = getSubByKey($post_list['data'], 'weiba_id'); $nameArr = $this->_getWeibaName($weiba_ids); foreach ($post_list['data'] as $k => $v) { $post_list['data'][$k]['weiba'] = $nameArr[$v['weiba_id']]; $post_list['data'][$k]['user'] = model('User')->getUserInfo($v['post_uid']); $post_list['data'][$k]['replyuser'] = model('User')->getUserInfo($v['last_reply_uid']); // $images = matchImages($v['content']); // $images[0] && $post_list['data'][$k]['image'] = array_slice( $images , 0 , 5 ); $image = getEditorImages($v['content']); !empty($image) && ($post_list['data'][$k]['image'] = array($image)); } }
public function post() { if ($this->key != "") { if (t($_GET['Stime']) && t($_GET['Etime'])) { $Stime = strtotime(t($_GET['Stime'])); $Etime = strtotime(t($_GET['Etime'])); $this->assign('Stime', t($_GET['Stime'])); $this->assign('Etime', t($_GET['Etime'])); } $map['title'] = array('like', '%' . $this->key . '%'); $map['is_del'] = 0; $list = M('weiba_post')->where($map)->findPage(20); $weiba_ids = getSubByKey($list['data'], 'weiba_id'); $nameArr = $this->_getWeibaName($weiba_ids); foreach ($list['data'] as $k => $v) { $list['data'][$k]['weiba'] = $nameArr[$v['weiba_id']]; $list['data'][$k]['user'] = model('User')->getUserInfo($v['post_uid']); $list['data'][$k]['replyuser'] = model('User')->getUserInfo($v['last_reply_uid']); // $images = matchImages($v['content']); // $images[0] && $list['data'][$k]['image'] = array_slice( $images , 0 , 5 ); $image = getEditorImages($v['content']); !empty($image) && ($list['data'][$k]['image'] = array($image)); //匹配图片的src preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $v['content'], $match); foreach ($match[1] as $imgurl) { $imgurl = $imgurl; if (!empty($imgurl)) { $list['data'][$k]['img'][] = $imgurl; } } $is_digg = M('weiba_post_digg')->where('post_id=' . $v['post_id'] . ' and uid=' . $this->mid)->find(); $list['data'][$k]['digg'] = $is_digg ? 'digg' : 'undigg'; $list['data'][$k]['content'] = t($list['data'][$k]['content']); //去掉微吧已经删除的 $is_del = D('weiba')->where('weiba_id=' . $v['weiba_id'])->getField('is_del'); if ($is_del == 1 || $is_del == null) { unset($list['data'][$k]); } } //dump($list);exit; $this->assign('searchResult', $list); } $this->display(); }
protected function weiba_postZan($ismy, $count = false) { if ($ismy) { $where = array('uid' => $this->mid); } else { $dbprefix = C('DB_PREFIX'); $sql = "SELECT post_id FROM {$dbprefix}weiba_post WHERE post_uid={$this->mid}"; $where = array('post_id' => array('in', $sql)); } if ($count) { return M('WeibaPostDigg')->where($where)->count(); } $result = D('WeibaPostDigg')->where($where)->order('cTime DESC')->findPage(); $weibaPostModel = D('WeibaPost'); foreach ($result['data'] as &$rs) { $user = getUserInfo($rs['uid']); $rs['face'] = $user['avatar_small']; $rs['uname'] = $user['uname']; $rs['space'] = $user['space_url']; $rs['ctime'] = $rs['cTime']; $rs['data_id'] = $rs['post_id']; $rs['data_type'] = 'weiba_post'; $post = $weibaPostModel->field('title,content,is_del')->find($rs['post_id']); if ($post && $post['is_del'] == 0) { $rs['source_url'] = U('weiba/Index/postDetail', array('post_id' => $rs['post_id'])); $rs['source_content'] = '帖子|' . $post['title'] . '-' . getShort(t($post['content']), 15); $image = getEditorImages($post['content']); if ($image) { $rs['source_image'] = $image; $imageLocal = str_replace(UPLOAD_URL, '', $image); if ($image != $imageLocal) { $imageLocal = getImageUrl($imageLocal, 120, 120, true); if ($imageLocal) { $rs['source_image'] = $imageLocal; } } } } else { $rs['source_content'] = '原帖子已被删除了~'; } } return $result; }
/** * 帖子列表 */ private function _post_list($post_type, $limit) { $db_prefix = C('DB_PREFIX'); switch ($post_type) { case 'reply': $sql = "SELECT a.* FROM `{$db_prefix}weiba_post` a, `{$db_prefix}weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`is_del` = 0 ) ORDER BY a.last_reply_time desc LIMIT " . $limit; break; case 'hot': $sql = "SELECT a.* FROM `{$db_prefix}weiba_post` a, `{$db_prefix}weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`is_del` = 0 ) ORDER BY a.reply_all_count desc LIMIT " . $limit; break; case 'digest': $sql = "SELECT a.* FROM `{$db_prefix}weiba_post` a, `{$db_prefix}weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`digest` = 1 ) AND ( a.`is_del` = 0 ) ORDER BY a.post_time desc LIMIT " . $limit; break; case 'recommend': $sql = "SELECT a.* FROM `{$db_prefix}weiba_post` a, `{$db_prefix}weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`recommend` = 1 ) AND ( a.`is_del` = 0 ) ORDER BY a.recommend_time desc LIMIT " . $limit; break; case 'top': $sql = "SELECT a.* FROM `{$db_prefix}weiba_post` a, `{$db_prefix}weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`top` = 2 ) AND ( a.`is_del` = 0 ) ORDER BY a.last_reply_time desc LIMIT " . $limit; break; case 'nrecommend': $sql = "SELECT a.* FROM `{$db_prefix}weiba_post` a, `{$db_prefix}weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`top` = 2 ) AND ( a.`is_del` = 0 ) ORDER BY a.top_time desc LIMIT " . $limit; break; case 'topandrecomment': $sql = "SELECT a.* FROM `{$db_prefix}weiba_post` a, `{$db_prefix}weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`recommend` = 1 ) AND ( a.`is_del` = 0 ) ORDER BY a.top desc,a.last_reply_time desc"; break; default: //new $sql = "SELECT a.* FROM `{$db_prefix}weiba_post` a, `{$db_prefix}weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`is_del` = 0 ) ORDER BY a.post_time desc LIMIT " . $limit; break; } $post_list = D('weiba_post')->query($sql); $weiba_ids = getSubByKey($post_list, 'weiba_id'); $nameArr = $this->_getWeibaName($weiba_ids); foreach ($post_list as $k => $v) { $post_list[$k]['weiba'] = $nameArr[$v['weiba_id']]; $post_list[$k]['user'] = model('User')->getUserInfo($v['post_uid']); $post_list[$k]['replyuser'] = model('User')->getUserInfo($v['last_reply_uid']); // $images = matchImages($v['content']); // $images[0] && $post_list[$k]['image'] = array_slice( $images , 0 , 5 ); $image = getEditorImages($v['content']); !empty($image) && ($post_list[$k]['image'] = array($image)); //匹配图片的src preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $v['content'], $match); foreach ($match[1] as $imgurl) { $imgurl = $imgurl; if (!empty($imgurl)) { $post_list[$k]['img'][] = $imgurl; } } } return $post_list; }
/** * 我的首页 - 分享页面 * * @return void */ public function index() { redirect(U('square/index/index')); /* # 微吧和频道开关检测 */ $weibaIfOpen = model('App')->getAppByName('weiba'); $weibaIfOpen = $weibaIfOpen['status']; $channelIfOpen = model('App')->getAppByName('channel'); $channelIfOpen = $channelIfOpen['status']; $this->assign('weibaIfOpen', $weibaIfOpen); $this->assign('channelIfOpen', $channelIfOpen); unset($weibaIfOpen, $channelIfOpen); // 安全过滤 $d['type'] = t($_GET['type']) ? t($_GET['type']) : 'all'; $d['feed_type'] = t($_GET['feed_type']) ? t($_GET['feed_type']) : ''; $d['feed_key'] = t($_GET['feed_key']) ? t($_GET['feed_key']) : ''; // 关注的人 if ($d['type'] === 'following') { $d['groupname'] = L('PUBLIC_ACTIVITY_STREAM'); // 我关注的 $d['followGroup'] = model('FollowGroup')->getGroupList($this->mid); foreach ($d['followGroup'] as $v) { if ($v['follow_group_id'] == t($_REQUEST['fgid'])) { $d['groupname'] = $v['title']; break; } } } // 判断频道是否开启 $isChannelOpen = model('App')->isAppNameOpen('channel'); $this->assign('isChannelOpen', $isChannelOpen); // 关注的频道 if ($isChannelOpen && $d['type'] === 'channel') { $d['channelname'] = '我关注的频道'; $d['channelGroup'] = D('ChannelFollow', 'channel')->getFollowList($this->mid); foreach ($d['channelGroup'] as $v) { if ($v['channel_category_id'] == t($_REQUEST['fgid'])) { $d['channelname'] = $v['title']; break; } } } $this->assign($d); // 设置默认话题 $weiboSet = model('Xdata')->get('admin_Config:feed'); $initHtml = $weiboSet['weibo_default_topic']; // 分享框默认话题 if ($initHtml) { $initHtml = '#' . $initHtml . '#'; } $this->assign('initHtml', $initHtml); if ($d['type'] == 'weiba') { $sfollow = D('weiba_follow')->where('follower_uid=' . $this->mid)->findAll(); if ($sfollow) { $idlist = getSubByKey($sfollow, 'weiba_id'); foreach ($idlist as $k => $vo) { if (in_array($vo, $fids)) { unset($idlist[$k]); } } $maps['weiba_id'] = array('in', $idlist); } $order = ' top desc, post_time desc'; $list = D('weiba_post')->where($maps)->order($order)->findpage(10); foreach ($list['data'] as $k => $v) { $list['data'][$k]['weiba'] = $nameArr[$v['weiba_id']]; $list['data'][$k]['user'] = model('User')->getUserInfo($v['post_uid']); $list['data'][$k]['replyuser'] = model('User')->getUserInfo($v['last_reply_uid']); // $images = matchImages($v['content']); // $images[0] && $list['data'][$k]['image'] = array_slice( $images , 0 , 5 ); $image = getEditorImages($v['content']); !empty($image) && ($list['data'][$k]['image'] = array($image)); // 匹配图片的src preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $v['content'], $match); foreach ($match[1] as $imgurl) { $imgurl = $imgurl; if (!empty($imgurl)) { $list['data'][$k]['img'][] = $imgurl; } } $is_digg = M('weiba_post_digg')->where('post_id=' . $v['post_id'] . ' and uid=' . $this->mid)->find(); $list['data'][$k]['digg'] = $is_digg ? 'digg' : 'undigg'; $list['data'][$k]['content'] = t($list['data'][$k]['content']); // dump($userinfo);avatar_small,avatar_tiny $list['data'][$k]['image'] = $list['data'][$k]['user']['avatar_middle']; } // dump($list);exit; $this->assign('post_recommend_list', $list); } $title = empty($weiboSet['weibo_send_info']) ? '随时记录' : $weiboSet['weibo_send_info']; $this->assign('title', $title); // 设置标题与关键字信息 switch ($d['type']) { case 'all': $this->setTitle('朋友圈'); $this->setKeywords('朋友圈'); break; case 'recommend': $this->setTitle('朋友圈-推荐动态'); $this->setKeywords('朋友圈-推荐动态'); break; case 'following': $this->setTitle('朋友圈-我关注的动态'); $this->setKeywords('朋友圈-我关注的动态'); break; case 'weiba': $this->setTitle('朋友圈-我关注的微吧'); $this->setKeywords('朋友圈-我关注的微吧'); break; case 'channel': $this->setTitle('朋友圈-我关注的频道'); $this->setKeywords('朋友圈-我关注的频道'); break; case 'newall': $this->setTitle('朋友圈-最新动态'); $this->setKeywords('朋友圈-最新动态'); break; default: $this->setTitle(L('PUBLIC_INDEX_INDEX')); $this->setKeywords(L('PUBLIC_INDEX_INDEX')); } /* * $category = D ( 'BlogCategory' )->getCategory (); $this->assign ( 'blog_category', $category ); */ $category = model('CategoryTree')->setTable('channel_category')->getCategoryList(); $this->assign('channel_category', $category); $wtype = array('at', 'topic', 'contribute'); $actions = array(); foreach ($wtype as $value) { $actions[$value] = false; } $this->assign('actions', $actions); // 获取后台配置数据 -- 提示语 $channelConf = model('Xdata')->get('channel_Admin:index'); $prompt = ''; if ($channelConf['is_audit'] == 1) { $prompt = '投稿成功'; } else { $prompt = '投稿正在审核中'; } $sfollow = D('weiba_follow')->where('follower_uid=' . $this->mid)->findAll(); unset($map); $map['weiba_id'] = array('in', getSubByKey($sfollow, 'weiba_id')); $map['is_del'] = 0; $map['status'] = 1; $wcategory = D('Weiba')->where($map)->field('weiba_id,weiba_name')->findAll(); $this->assign('weiba_category', $wcategory); $this->display(); }
public function collection() { $this->_top(); $this->_assignUserInfo($this->uid); // 获取信息 if ($_GET['feed_type'] == 'weiba') { $map['uid'] = $this->uid; $post = M('weiba_favorite')->where($map)->select(); $maps['post_id'] = array('in', getSubByKey($post, 'post_id')); $weiba = M('weiba_post')->where($maps)->select(); $weiba_ids = getSubByKey($weiba, 'weiba_id'); $nameArr = $this->_getWeibaName($weiba_ids); foreach ($weiba as $k => $v) { $weiba[$k]['weiba'] = $nameArr[$v['weiba_id']]; $weiba[$k]['user'] = model('User')->getUserInfo($v['post_uid']); $weiba[$k]['replyuser'] = model('User')->getUserInfo($v['last_reply_uid']); // $images = matchImages($v['content']); // $images[0] && $weiba[$k]['image'] = array_slice( $images , 0 , 5 ); $image = getEditorImages($v['content']); !empty($image) && ($weiba[$k]['image'] = array($image)); // 匹配图片的src preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $v['content'], $match); foreach ($match[1] as $imgurl) { $imgurl = $imgurl; if (!empty($imgurl)) { $weiba[$k]['img'][] = $imgurl; } } $is_digg = M('weiba_post_digg')->where('post_id=' . $v['post_id'] . ' and uid=' . $this->mid)->find(); $weiba[$k]['digg'] = $is_digg ? 'digg' : 'undigg'; $weiba[$k]['content'] = t($weiba[$k]['content']); } $this->assign('weiba', $weiba); } $this->display(); }
public function profileContent($uid) { if ($_GET['feed_type'] == 'weiba') { $sfollow = D('weiba_follow')->where('follower_uid=' . $uid)->findAll(); $map['weiba_id'] = array('in', getSubByKey($sfollow, 'weiba_id')); $map['is_del'] = 0; $map['status'] = 1; $map['uid'] = array('neq', $uid); $post_list = D('weiba')->where($map)->findPage(20); //帖子推荐 $sql = "SELECT a.* FROM `ts_weiba_post` a, `ts_weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`recommend` = 1 ) AND ( a.`is_del` = 0 ) ORDER BY a.recommend_time desc LIMIT 10"; $slist = D('weiba_post')->query($sql); $weiba_ids = getSubByKey($post_list['data'], 'weiba_id'); $nameArr = $this->_getWeibaName($weiba_ids); foreach ($post_list['data'] as $k => $v) { $post_list['data'][$k]['weiba'] = $nameArr[$v['weiba_id']]; $post_list['data'][$k]['user'] = model('User')->getUserInfo($v['post_uid']); $post_list['data'][$k]['replyuser'] = model('User')->getUserInfo($v['last_reply_uid']); // $images = matchImages($v['content']); // $images[0] && $list['data'][$k]['image'] = array_slice( $images , 0 , 5 ); $image = getEditorImages($v['content']); !empty($image) && ($post_list['data'][$k]['image'] = array($image)); //匹配图片的src preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $v['content'], $match); foreach ($match[1] as $imgurl) { $imgurl = $imgurl; if (!empty($imgurl)) { $post_list['data'][$k]['img'][] = $imgurl; } } $is_digg = M('weiba_post_digg')->where('post_id=' . $v['post_id'] . ' and uid=' . $this->mid)->find(); $post_list['data'][$k]['digg'] = $is_digg ? 'digg' : 'undigg'; $post_list['data'][$k]['content'] = t($post_list['data'][$k]['content']); if ($v['new_day'] != date("Y-m-d", time())) { $post_list['data'][$k]['new_count'] = 0; $this->setNewcount($v['weiba_id'], 0); } } foreach ($slist as $i => $s) { $user = model('User')->getUserInfo($s['post_uid']); $slist[$i]['weiba'] = $user['uname']; } //dump($post_list);exit; //dump(D ()->getLastSql()); //dump($slist); $post_list['post_recommend_list'] = $slist; $tpl = APPS_PATH . '/weiba/Tpl/default/Index/profileWeiba.html'; } else { if ($_GET['feed_type'] == 'cweiba') { $map['uid'] = $uid; $map['is_del'] = 0; if ($uid != $_SESSION['mid']) { $map['status'] = 1; } $map['status'] = array('in', array('0', '1')); $post_list = D('weiba')->where($map)->findPage(20); //帖子推荐 $sql = "SELECT a.* FROM `ts_weiba_post` a, `ts_weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`recommend` = 1 ) AND ( a.`is_del` = 0 ) ORDER BY a.recommend_time desc LIMIT 10"; $slist = D('weiba_post')->query($sql); foreach ($post_list['data'] as $k => $v) { if ($v['new_day'] != date("Y-m-d", time())) { $post_list['data'][$k]['new_count'] = 0; $this->setNewcount($v['weiba_id'], 0); } } foreach ($slist as $i => $s) { $user = model('User')->getUserInfo($s['post_uid']); $slist[$i]['weiba'] = $user['uname']; } //dump(D ()->getLastSql()); //dump($slist); $post_list['post_recommend_list'] = $slist; $post_list['mid'] = $_SESSION['mid']; $tpl = APPS_PATH . '/weiba/Tpl/default/Index/profileCweiba.html'; } else { $map['post_uid'] = $uid; $map['is_del'] = 0; $post_list = D('weiba_post')->where($map)->order('post_time DESC')->findPage(20); $weiba_ids = getSubByKey($post_list['data'], 'weiba_id'); $nameArr = $this->_getWeibaName($weiba_ids); foreach ($post_list['data'] as $k => $v) { $post_list['data'][$k]['weiba'] = $nameArr[$v['weiba_id']]; $post_list['data'][$k]['user'] = model('User')->getUserInfo($v['post_uid']); $post_list['data'][$k]['replyuser'] = model('User')->getUserInfo($v['last_reply_uid']); $image = getEditorImages($v['content']); !empty($image) && ($post_list['data'][$k]['image'] = array($image)); } //帖子推荐 $sql = "SELECT a.* FROM `ts_weiba_post` a, `ts_weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( b.`status` = 1 ) AND ( a.`recommend` = 1 ) AND ( a.`is_del` = 0 ) ORDER BY a.recommend_time desc LIMIT 10"; $slist = D('weiba_post')->query($sql); //dump(D ()->getLastSql()); foreach ($slist as $i => $s) { $user = model('User')->getUserInfo($s['post_uid']); $slist[$i]['weiba'] = $user['uname']; } //dump($slist);exit; $post_list['post_recommend_list'] = $slist; $tpl = APPS_PATH . '/weiba/Tpl/default/Index/profileContent.html'; } } $post_list['uid'] = $uid; return fetch($tpl, $post_list); }